All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.space.kscience.dataforge.io.EnvelopeFormat.kt Maven / Gradle / Ivy

package space.kscience.dataforge.io

import kotlinx.io.Source
import space.kscience.dataforge.context.Context
import space.kscience.dataforge.io.EnvelopeFormatFactory.Companion.ENVELOPE_FORMAT_TYPE
import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.misc.DfId
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.asName
import kotlin.reflect.KType
import kotlin.reflect.typeOf

public interface EnvelopeFormat : IOFormat {

    override val type: KType get() = typeOf()
}

public fun EnvelopeFormat.read(input: Source): Envelope = readFrom(input)

@DfId(ENVELOPE_FORMAT_TYPE)
public interface EnvelopeFormatFactory : IOFormatFactory, EnvelopeFormat {
    override val type: KType get() = typeOf()

    override fun build(context: Context, meta: Meta): EnvelopeFormat

    /**
     * Try to infer specific format from input and return null if the attempt is failed.
     * This method does **not** return Input into initial state.
     */
    public fun peekFormat(io: IOPlugin, binary: Binary): EnvelopeFormat?

    public companion object {
        public val ENVELOPE_FACTORY_NAME: Name = "envelope".asName()
        public const val ENVELOPE_FORMAT_TYPE: String = "io.format.envelope"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy