moonrdiff

    Incremental rdiff-compatible signatures, deltas and patch decoding in MoonBit.

    rdiff
    delta
    sync
    incremental
    binary
    Download zip
    Version
    0.1.3
    License
    MIT AND Apache-2.0
    Last updated
    6 days ago
    Downloads
    124

    serikaonoe123/moonrdiff does not have a README file

    DeltaError

    pub suberror DeltaError {
    Invalid(String)
    }

    DeltaEncoder

    pub struct DeltaEncoder {
    // private fields
    }

    is at most one block and literals at most 64 KiB. Drain every returned batch.

    DeltaEncoder::finish

    fn DeltaEncoder::finish(self : DeltaEncoder) -> Bytes raise DeltaError

    DeltaEncoder::new

    fn DeltaEncoder::new(signature : Signature, basis_size~ : Int, max_candidate_checks? : Int, max_delta_size? : Int, max_target_size? : Int) -> DeltaEncoder raise DeltaError

    DeltaEncoder::push

    fn DeltaEncoder::push(self : DeltaEncoder, chunk : BytesView) -> Bytes raise DeltaError

    Failure poisons the encoder. Literal fallback shares one global budget.

    Instruction

    pub(all) enum Instruction {
    Literal(Bytes)
    Copy(offset~ : Int, length~ : Int)
    }

    A description of the target bytes; Copy always addresses the old basis.

    PatchDecoder

    pub struct PatchDecoder {
    // private fields
    }

    Caller must consume each batch; this object does not read or retain basis bytes.

    PatchDecoder::finish

    fn PatchDecoder::finish(self : PatchDecoder) -> Unit raise DeltaError

    End of input is explicit; missing END or unfinished literal/header is an error.

    PatchDecoder::new

    fn PatchDecoder::new(basis_size~ : Int, max_output~ : Int, max_instructions? : Int) -> PatchDecoder raise DeltaError

    PatchDecoder::push

    fn PatchDecoder::push(self : PatchDecoder, chunk : BytesView) -> Array[Instruction] raise DeltaError

    A failed batch may have advanced state; errors permanently poison this decoder.

    Signature

    pub struct Signature {
    // private fields
    }

    Validated RK/BLAKE2 signature. Block count does not encode basis file size.

    Signature::block_count

    fn Signature::block_count(self : Signature) -> Int

    Signature::to_bytes

    fn Signature::to_bytes(self : Signature) -> Bytes

    Serialize a validated signature without changing its record order.

    SignatureEncoder

    pub struct SignatureEncoder {
    // private fields
    }

    Each push returns only newly encoded bytes, which the caller must drain.

    SignatureEncoder::buffered_bytes

    fn SignatureEncoder::buffered_bytes(self : SignatureEncoder) -> Int

    SignatureEncoder::finish

    fn SignatureEncoder::finish(self : SignatureEncoder) -> Bytes raise DeltaError

    Emit the final short block; even an empty stream emits a valid header.

    SignatureEncoder::new

    fn SignatureEncoder::new(block_size? : Int, strong_length? : Int, max_blocks? : Int, max_output? : Int) -> SignatureEncoder raise DeltaError

    SignatureEncoder::output_bytes

    fn SignatureEncoder::output_bytes(self : SignatureEncoder) -> Int

    SignatureEncoder::push

    fn SignatureEncoder::push(self : SignatureEncoder, chunk : BytesView) -> Bytes raise DeltaError

    Failed pushes poison the encoder; callers must discard partial output.

    delta

    fn delta(signature : Signature, target : Bytes, basis_size~ : Int, max_candidate_checks? : Int, max_delta_size? : Int) -> Bytes raise DeltaError

    Once the comparison budget is exhausted, remaining bytes become literals.

    encode

    fn encode(instructions : Array[Instruction]) -> Bytes raise DeltaError

    Encode explicit instructions; this is not yet a matching algorithm.

    parse_signature

    fn parse_signature(data : Bytes, max_blocks? : Int) -> Signature raise DeltaError

    Parse only RS_RK_BLAKE2 signatures, bounding allocation by block count.

    patch

    fn patch(basis : Bytes, delta : Bytes, max_output~ : Int) -> Bytes raise DeltaError

    Parameters above Int32 capacity are rejected even if valid in the format.

    signature

    fn signature(basis : Bytes, block_size? : Int, strong_length? : Int, max_blocks? : Int) -> Bytes raise DeltaError

    Generate one supported librsync signature profile in memory.