Sign in

    codec

    Error kinds and limits shared by the streaming codecs of gaato/codecs.mbt.

    codec
    compression
    streaming
    errors
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    yesterday
    Downloads
    49

    #gaato/codec

    The error kinds and limits shared by the streaming codecs of codecs.mbt. A codec of any kind, a byte-stream decoder or an image decoder, raises CodecError with one of these kinds through its kind's contract, so that callers handle failures the same way whatever they decode.

    This module only defines types. Byte-stream codecs implement gaato/codec_bytes; see the repository's CONTRACT.md for the rules they keep.

    CodecError

    pub(all) suberror CodecError {
    CodecError(ErrorKind, String)
    } derive(
    Debug
    )

    The error every codec raises through its kind's contract: a kind to act on, and a message for people.

    CodecError::kind

    fn CodecError::kind(self : CodecError) -> ErrorKind

    The kind of the error.

    ErrorKind

    pub(all) enum ErrorKind {
    Truncated
    Corrupt
    ChecksumMismatch
    TrailingData
    LimitExceeded(Limit)
    DictionaryRequired(UInt?)
    DictionaryMismatch
    Unsupported
    } derive(Eq,
    Debug
    )

    Why a codec stopped with an error. The same kinds serve every kind of codec (byte streams, images, audio), so that callers handle a failure the same way whatever they were decoding. New kinds may be added.

    ErrorKind::equal

    fn ErrorKind::equal(ErrorKind, ErrorKind) -> Bool

    ErrorKind::not_equal

    fn ErrorKind::not_equal(x : ErrorKind, y : ErrorKind) -> Bool

    Limit

    pub(all) struct Limit {
    resource : Resource
    needed : UInt64?
    limit : UInt64
    } derive(Eq,
    Debug
    )

    A limit a stream would exceed: what it is about, how much the stream needs when that is known, and how much is allowed. Amounts are in the resource's unit (bytes for memory and output).

    Limit::equal

    fn Limit::equal(Limit, Limit) -> Bool

    Limit::not_equal

    fn Limit::not_equal(x : Limit, y : Limit) -> Bool

    Limit::to_repr

    Resource

    pub(all) enum Resource {
    Memory
    Output
    } derive(Eq,
    Debug
    )

    What a limit is about. New resources may be added.

    Resource::equal

    fn Resource::equal(Resource, Resource) -> Bool

    Resource::not_equal

    fn Resource::not_equal(x : Resource, y : Resource) -> Bool

    Resource::to_repr

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io