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

    SampleRangeError

    pub(all) suberror SampleRangeError {
    InvalidSampleRange(Int, Int, Int)
    }

    Bounds supplied to the clipped decoder must be within the declared count.

    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.

    decode_range

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

    Retain only indices in [start, end). The full record must have the declared frame capacity and integrate through Xn, even for an empty range. Invalid bounds raise SampleRangeError. Invalid Steim data raises CodecError.

    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.

    to_big_endian

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

    Verify one Steim payload through Xn and return its frames in big-endian order. Keep the frame count, packing choices, d0 and the entire last word. Already big-endian payloads are returned unchanged. For little-endian input, unused words and controls after the declared samples are zeroed.

    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.