Saucexages v0.2.0 Saucexages.Sauce View Source
Functions for working with SAUCE.
Link to this section Summary
Functions
Total byte size of a sauce comments block, including the comment ID
Value of the sauce comment ID field
Byte size of the sauce comment ID field
Byte size of a single comment line in a sauce
Total byte size of all comment lines when stored
Returns the EOF (end-of-file) character value that should be used when reading or writing a SAUCE
Returns a list of metadata for each SAUCE record field, including calculated information such as field position
Returns a list of metadata for each SAUCE record field
Returns the zero-based binary offset within a SAUCE record for a given field_id
Returns the size of a SAUCE field in bytes. The byte size determines how much fixed-space in a SAUCE binary the field should occupy
Byte size limit for a file size (32-bit unsigned integer) according to SAUCE. Any file size bigger than this limit is set to zero or can be considered undefined
Max number of comment lines allowed according to the SAUCE spec
Minimum byte size of a comment block as required by SAUCE
Minimum byte size of a SAUCE block that includes at least one comment
Returns a list of field_ids consisting only of required fields for a SAUCE record. SAUCE binary that lacks these fields should be considered invalid
Returns a list of metadata consisting only of required fields for a SAUCE record. SAUCE binary that lacks these fields should be considered invalid
Total byte size of a sauce including the full comments block
Byte size of the sauce record fields, excluding the sauce_id
Value of the sauce ID field
Byte size of the sauce ID field
Byte size of just the sauce record fields
Default value of the sauce version field
Link to this section Types
field_id() :: :sauce_id | :version | :title | :author | :group | :date | :file_size | :data_type | :file_type | :t_info_1 | :t_info_2 | :t_info3 | :t_info_4 | :comment_lines | :t_flags | :t_info_s
Link to this section Functions
comment_block_byte_size(non_neg_integer()) :: non_neg_integer()
Total byte size of a sauce comments block, including the comment ID.
Examples
iex> Saucexages.Sauce.comment_block_byte_size(1)
69
iex> Saucexages.Sauce.comment_block_byte_size(2)
133
iex> Saucexages.Sauce.comment_block_byte_size(0)
0
Value of the sauce comment ID field.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.comment_id()
"COMNT"
comment_id_byte_size() :: pos_integer()
Byte size of the sauce comment ID field.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.comment_id_byte_size()
5
comment_line_byte_size() :: pos_integer()
Byte size of a single comment line in a sauce.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.comment_line_byte_size()
64
comments_byte_size(non_neg_integer()) :: non_neg_integer()
Total byte size of all comment lines when stored.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.comments_byte_size(1)
64
iex> Saucexages.Sauce.comments_byte_size(2)
128
Returns the EOF (end-of-file) character value that should be used when reading or writing a SAUCE.
Returns a list of metadata for each SAUCE record field, including calculated information such as field position.
Returns a list of metadata for each SAUCE record field.
field_position(field_id(), boolean()) :: non_neg_integer()
Returns the zero-based binary offset within a SAUCE record for a given field_id
.
Optionally, you may pass a boolean to indicate if the field is offset from the SAUCE sauce_id
field.
Useful for jumping to the exact start position of a field, building binaries, constructing matches, and avoiding sizing errors when working with SAUCE.
Used with field_size/1
, it can be helpful for working with SAUCE binaries efficiently.
Examples
iex> Saucexages.Sauce.field_position(:title)
7
iex> Saucexages.Sauce.field_position(:title, true)
2
iex> Saucexages.Sauce.field_position(:sauce_id)
0
iex> Saucexages.Sauce.field_position(:t_info_s)
106
Returns the size of a SAUCE field in bytes. The byte size determines how much fixed-space in a SAUCE binary the field should occupy.
Useful for building binaries, constructing matches, and avoiding sizing errors when working with SAUCE.
Only matches valid SAUCE fields.
Examples
iex> Saucexages.Sauce.field_size(:title)
35
iex> Saucexages.Sauce.field_size(:t_info_1)
2
Byte size limit for a file size (32-bit unsigned integer) according to SAUCE. Any file size bigger than this limit is set to zero or can be considered undefined.
Examples
iex> Saucexages.Sauce.file_size_limit()
4294967295
Max number of comment lines allowed according to the SAUCE spec.
Examples
iex> Saucexages.Sauce.max_comment_lines()
255
minimum_comment_block_byte_size() :: pos_integer()
Minimum byte size of a comment block as required by SAUCE.
The minimum requirement for a comment block is that it includes the comment id (COMNT) and enough space for 1 comment line (64 bytes).
Examples
iex> Saucexages.Sauce.minimum_comment_block_byte_size()
69
minimum_commented_sauce_size() :: pos_integer()
Minimum byte size of a SAUCE block that includes at least one comment.
Examples
iex> Saucexages.Sauce.minimum_commented_sauce_size()
197
Returns a list of field_ids consisting only of required fields for a SAUCE record. SAUCE binary that lacks these fields should be considered invalid.
Examples
iex> Saucexages.Sauce.required_field_ids()
[:sauce_id, :version, :data_type, :file_type]
Returns a list of metadata consisting only of required fields for a SAUCE record. SAUCE binary that lacks these fields should be considered invalid.
sauce_byte_size(non_neg_integer()) :: pos_integer()
Total byte size of a sauce including the full comments block.
Examples
iex> Saucexages.Sauce.sauce_byte_size(1)
197
iex> Saucexages.Sauce.sauce_byte_size(2)
261
sauce_data_byte_size() :: pos_integer()
Byte size of the sauce record fields, excluding the sauce_id.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.sauce_data_byte_size()
123
Value of the sauce ID field.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.sauce_id()
"SAUCE"
sauce_record_byte_size() :: pos_integer()
Byte size of just the sauce record fields.
Useful for constructing binaries and matching.
Examples
iex> Saucexages.Sauce.sauce_record_byte_size()
128