XinOrigin/moon_warc/codec does not have a README file

    CodecError

    pub(all) enum CodecError {
    HeaderError(
    HeaderError
    )
    UnexpectedEof(String)
    InvalidTrailingSeparator(String)
    InvalidContentLength(String)
    LimitExceeded(String)
    GzipError(
    GzipError
    )
    } derive(Eq,
    Debug
    )

    Errors returned by the Sans-IO streaming WARC reader.

    ReaderLimits

    pub(all) struct ReaderLimits {
    max_header_bytes : Int
    max_payload_bytes : Int
    } derive(Eq,
    Debug
    )

    Resource bounds enforced by WarcReader to guard against untrusted oversized frames.

    ReaderLimits::default

    fn ReaderLimits::default() -> ReaderLimits

    Default reader limits (64 KiB max header block, 64 MiB max payload).

    ReaderState

    type ReaderState

    WarcGzReader

    pub struct WarcGzReader {
    // private fields
    }

    Chunk-incremental Sans-IO streaming reader for single- and multi-member RFC 1952 .warc.gz archives. Buffers only the currently incomplete compressed Gzip member across feed() calls and frees compressed & uncompressed member buffers immediately after each member completes.

    WarcGzReader::bytes_consumed

    fn WarcGzReader::bytes_consumed(self : WarcGzReader) -> Int64

    Returns the cumulative number of compressed .warc.gz stream bytes consumed from completed members.

    WarcGzReader::feed

    fn WarcGzReader::feed(self : WarcGzReader, chunk : BytesView) -> Unit

    Appends a compressed .warc.gz chunk into the streaming reader buffer.

    WarcGzReader::finish

    fn WarcGzReader::finish(self : WarcGzReader) -> Result[Unit, CodecError]

    Checks that no unconsumed or truncated trailing Gzip member bytes remain at EOF.

    WarcGzReader::new

    fn WarcGzReader::new(limits? : ReaderLimits) -> WarcGzReader

    Creates a fresh incremental .warc.gz streaming reader.

    WarcGzReader::next_record

    fn WarcGzReader::next_record(self : WarcGzReader) -> Result[WarcRecord?, CodecError]

    Advances the .warc.gz streaming parser and yields the next complete WarcRecord, if available.

    WarcReader

    pub struct WarcReader {
    // private fields
    }

    Sans-IO incremental streaming parser for ISO 28500 WARC 1.0/1.1 archives.

    WarcReader::bytes_consumed

    fn WarcReader::bytes_consumed(self : WarcReader) -> Int64

    Returns the cumulative number of uncompressed WARC stream bytes consumed so far.

    WarcReader::feed

    fn WarcReader::feed(self : WarcReader, chunk : BytesView) -> Unit

    Appends raw archive bytes into the streaming reader buffer.

    WarcReader::finish

    fn WarcReader::finish(self : WarcReader) -> Result[Unit, CodecError]

    Validates that no partial header, payload, or trailing separator remains at EOF.

    WarcReader::new

    fn WarcReader::new(limits? : ReaderLimits) -> WarcReader

    Creates a fresh streaming WarcReader.

    WarcReader::next_record

    fn WarcReader::next_record(self : WarcReader) -> Result[WarcRecord?, CodecError]

    Advances the streaming parser and yields the next complete WarcRecord, if available.

    WarcReader::set_bytes_consumed

    fn WarcReader::set_bytes_consumed(self : WarcReader, offset : Int64) -> Unit

    Sets the starting stream byte offset before parsing resumes (for windowed/multi-part streams).

    WarcRecord

    pub(all) struct WarcRecord {
    header :
    WarcHeader

    payload : Bytes
    offset : Int64
    record_length : Int64
    } derive(Eq,
    Debug
    )

    Decoded ISO 28500 WARC record with exact byte offset and total encoded length.

    build_conversion

    fn build_conversion(record_id~ : String, date~ : String, target_uri~ : String, content_type~ : String, payload : Bytes, refers_to? : String, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 conversion record.

    build_http_exchange

    fn build_http_exchange(request_id~ : String, response_id~ : String, metadata_id? : String, date~ : String, target_uri~ : String, request_bytes~ : Bytes, response_bytes~ : Bytes, metadata_bytes? : Bytes, version? :
    WarcVersion
    ) -> Array[WarcRecord]

    Builds linked ISO 28500 request, response, and optional metadata records for a single crawled HTTP exchange, automatically wiring WARC-Concurrent-To links across records.

    build_metadata

    fn build_metadata(record_id~ : String, date~ : String, target_uri~ : String, payload : Bytes, concurrent_to? : String, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 metadata record.

    build_request

    fn build_request(record_id~ : String, date~ : String, target_uri~ : String, payload : Bytes, concurrent_to? : String, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 request record (application/http; msgtype=request).

    build_resource

    fn build_resource(record_id~ : String, date~ : String, target_uri~ : String, content_type~ : String, payload : Bytes, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 resource record.

    build_response

    fn build_response(record_id~ : String, date~ : String, target_uri~ : String, payload : Bytes, concurrent_to? : String, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 response record (application/http; msgtype=response).

    build_revisit

    fn build_revisit(record_id~ : String, date~ : String, target_uri~ : String, profile~ : String, payload_digest~ : String, refers_to? : String, refers_to_target_uri? : String, refers_to_date? : String, payload? : Bytes, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 revisit record for deduplicating unchanged captures.

    build_warcinfo

    fn build_warcinfo(record_id~ : String, date~ : String, payload : Bytes, filename? : String, version? :
    WarcVersion
    ) -> WarcRecord

    Builds an ISO 28500 warcinfo record.

    encode_all

    fn encode_all(records : Array[WarcRecord], auto_digest? : Bool) -> Bytes

    Serializes an array of WarcRecords into a contiguous WARC archive byte stream.

    encode_all_gz

    fn encode_all_gz(records : Array[WarcRecord], auto_digest? : Bool, level? : Int) -> Bytes

    Serializes records as an RFC 1952 multi-member .warc.gz stream where each WARC record occupies an independent concatenated Gzip member (Common Crawl layout).

    encode_http_exchange_gz

    fn encode_http_exchange_gz(request_id~ : String, response_id~ : String, metadata_id? : String, date~ : String, target_uri~ : String, request_bytes~ : Bytes, response_bytes~ : Bytes, metadata_bytes? : Bytes, version? :
    WarcVersion
    , level? : Int) -> Bytes

    Captures a crawled HTTP exchange (request + response + optional metadata) directly as a validated multi-member .warc.gz byte stream with automatic SHA-256 block & payload digests.

    encode_record

    fn encode_record(record : WarcRecord, auto_digest? : Bool) -> Bytes

    Serializes a single WarcRecord to ISO 28500 wire bytes. When auto_digest is true (default), updates Content-Length, WARC-Block-Digest, and (for HTTP response records) WARC-Payload-Digest using SHA-256 Base32.

    encode_record_gz

    fn encode_record_gz(record : WarcRecord, auto_digest? : Bool, level? : Int) -> Bytes

    Serializes a single WarcRecord and wraps it in one RFC 1952 Gzip member.

    make_record

    fn make_record(version :
    WarcVersion
    , fields : Array[(String, String)], payload : Bytes) -> WarcRecord

    Constructs a WarcRecord with raw headers and payload (offset / record_length default to 0 until serialized).

    parse_all

    fn parse_all(raw : BytesView, limits? : ReaderLimits) -> Result[Array[WarcRecord], CodecError]

    Parses a complete WARC archive byte sequence into an array of WarcRecords.

    parse_all_gz

    fn parse_all_gz(raw : BytesView, limits? : ReaderLimits) -> Result[Array[WarcRecord], CodecError]

    Parses a single- or multi-member RFC 1952 .warc.gz byte stream into WarcRecords. Sets each record's offset and record_length to its enclosing gzip member's compressed byte offset and compressed length so CDXJ / CDX-11 indexes support HTTP range fetches.

    scan_all

    fn scan_all(raw : BytesView, limits? : ReaderLimits, on_record : (WarcRecord) -> Unit) -> Result[Int64, CodecError]

    Streams through a complete WARC byte sequence invoking on_record per decoded record without allocating a combined Array[WarcRecord] or copying the input buffer, returning the count.

    scan_all_gz

    fn scan_all_gz(raw : BytesView, limits? : ReaderLimits, on_record : (WarcRecord) -> Unit) -> Result[Int64, CodecError]

    Scans a single- or multi-member RFC 1952 .warc.gz byte stream record-by-record without retaining prior decompressed members or all decoded records in RAM, returning record count.