kent131452777/steimpack/codec does not have a README file

    CodecError

    pub(all) suberror CodecError {
    InvalidPayloadLength(Int)
    InvalidSampleCount(Int)
    InvalidFrameBudget(Int)
    InvalidFrameControl(Int)
    ReservedSteim2Mode(Int, Int, Int, Int)
    TooFewDifferences(Int, Int)
    ReverseConstantMismatch(Int, Int)
    }

    Frame and word positions are zero-based. Sample counts include the first integration constant, which corresponds to the first packed difference.
    impl Show for CodecError

    CodecError::to_string

    fn CodecError::to_string(self : CodecError) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    Encoding

    pub(all) enum Encoding {
    Steim1
    Steim2
    } derive(Eq)

    The two integer compression formats identified by miniSEED codes 10 and 11.

    decode

    fn decode(encoding : Encoding, payload : Bytes, sample_count : Int, little_endian? : Bool) -> Array[Int] raise CodecError

    Decode one record's consecutive 64-byte frames. Set little_endian for legacy miniSEED 2 payloads declared little-endian in blockette 1000. The sample count includes X0. The corresponding packed d0 links records and is skipped. After the declared count, Appendix B of SEED 2.4 allows unused fields and words. The final decoded sample must match Xn.

    A zero sample count returns an empty array. At most 16,777,216 samples can be decoded in one call.

    encode

    fn encode(encoding : Encoding, samples : ArrayView[Int], max_frames~ : Int) -> (Bytes, Int) raise CodecError

    Encode the longest prefix fitting max_frames consecutive 64-byte big-endian Steim frames and return the payload and consumed sample count. The first difference is zero so each record can be decoded independently. Steim-2 starts a new record at a step outside its signed 30-bit range. Continue with samples[count:] to encode the rest of the series.

    A positive budget is required. Empty input returns zero bytes and zero samples. A single call consumes at most 16,777,216 samples.

    verify

    fn verify(encoding : Encoding, payload : Bytes, sample_count : Int, little_endian? : Bool) -> Unit raise CodecError

    Validate the packed differences and Xn using the same rules as decode, keeping only the running sample value and count.