One CRAM block header and its compressed payload (CRAMv3 §8).
The payload is the on-disk compressed bytes. This struct does not hold an
inflated copy. raw_size is the declared uncompressed size.
Summary
Functions
Name for a content-type byte.
True when byte is a method this library can name.
Name for a compression method byte.
Types
@type t() :: %CRAM.Block{ compressed_size: non_neg_integer(), content_id: integer(), content_type: non_neg_integer(), content_type_name: atom(), crc32: non_neg_integer(), crc32_ok: boolean(), data: binary(), method: non_neg_integer(), method_name: atom(), offset: non_neg_integer(), raw_size: non_neg_integer(), slice: CRAM.SliceHeader.t() | nil }
One block.
:offset— byte offset of the block header:method— compression method byte:method_name—:raw,:gzip,:bzip2,:lzma,:rans4x8,:rans4x16,:adaptive_arithmetic,:fqzcomp,:name_tokenizer, or:unknown:content_type— content-type byte:content_type_name—:file_header,:compression_header,:slice_header,:external_data,:core_data, or:unknown:content_id— block content id:compressed_size— payload size on disk:raw_size— declared uncompressed size:crc32— stored CRC32:crc32_ok— whether the stored CRC matches the payload:data— compressed payload:slice— parsed slice header, ornilwhen this block is not oneiex> %CRAM.Block{method: 1, method_name: :gzip, content_type: 0, content_type_name: :file_header, content_id: 0, compressed_size: 0, raw_size: 0, crc32: 0, crc32_ok: true, data: <<>>, offset: 0}.method_name :gzip
Functions
@spec content_type_name(non_neg_integer()) :: atom()
Name for a content-type byte.
byte is an integer. Known values are 0, 1, 2, 4, and 5. There is no type
Any other integer is
:unknown. Does not raise.iex> CRAM.Block.content_type_name(0) :file_header iex> CRAM.Block.content_type_name(3) :unknown
@spec known_method?(non_neg_integer()) :: boolean()
True when byte is a method this library can name.
False for any other integer, including a negative one. Does not raise.
iex> CRAM.Block.known_method?(0)
true
iex> CRAM.Block.known_method?(99)
false
@spec method_name(non_neg_integer()) :: atom()
Name for a compression method byte.
byte is an integer. Bytes 0 through 8 use the names in the type docs.
Any other integer is :unknown. Does not raise.
iex> CRAM.Block.method_name(1)
:gzip
iex> CRAM.Block.method_name(99)
:unknown