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

Link to this type field_id() View Source
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

Link to this function comment_block_byte_size(comment_lines) View Source
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
Link to this macro comment_id() View Source (macro)
comment_id() :: String.t()

Value of the sauce comment ID field.

Useful for constructing binaries and matching.

Examples

iex> Saucexages.Sauce.comment_id()
"COMNT"
Link to this macro comment_id_byte_size() View Source (macro)
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
Link to this macro comment_line_byte_size() View Source (macro)
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
Link to this function comments_byte_size(comment_lines) View Source
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
Link to this macro eof_character() View Source (macro)
eof_character() :: integer()

Returns the EOF (end-of-file) character value that should be used when reading or writing a SAUCE.

Link to this macro field_list() View Source (macro)
field_list() :: [map()]

Returns a list of metadata for each SAUCE record field, including calculated information such as field position.

Link to this macro field_mappings() View Source (macro)
field_mappings() :: [map()]

Returns a list of metadata for each SAUCE record field.

Link to this macro field_position(field_id, offset? \\ false) View Source (macro)
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
Link to this macro field_size(field_id) View Source (macro)
field_size(field_id()) :: pos_integer()

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
Link to this macro file_size_limit() View Source (macro)
file_size_limit() :: pos_integer()

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
Link to this macro is_comment_block(comment_lines) View Source (macro)
Link to this macro is_comment_lines(comment_lines) View Source (macro)
Link to this macro max_comment_lines() View Source (macro)
max_comment_lines() :: pos_integer()

Max number of comment lines allowed according to the SAUCE spec.

Examples

iex> Saucexages.Sauce.max_comment_lines()
255
Link to this macro minimum_comment_block_byte_size() View Source (macro)
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
Link to this macro minimum_commented_sauce_size() View Source (macro)
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
Link to this macro required_field_ids() View Source (macro)
required_field_ids() :: [field_id()]

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]
Link to this macro required_fields() View Source (macro)
required_fields() :: [map()]

Returns a list of metadata consisting only of required fields for a SAUCE record. SAUCE binary that lacks these fields should be considered invalid.

Link to this function sauce_byte_size(comment_lines) View Source
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
Link to this macro sauce_data_byte_size() View Source (macro)
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
Link to this macro sauce_id() View Source (macro)
sauce_id() :: String.t()

Value of the sauce ID field.

Useful for constructing binaries and matching.

Examples

iex> Saucexages.Sauce.sauce_id()
"SAUCE"
Link to this macro sauce_id_byte_size() View Source (macro)
sauce_id_byte_size() :: pos_integer()

Byte size of the sauce ID field.

Examples

iex> Saucexages.Sauce.sauce_id_byte_size()
5
Link to this macro sauce_record_byte_size() View Source (macro)
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
Link to this macro sauce_version() View Source (macro)
sauce_version() :: String.t()

Default value of the sauce version field.

Examples

iex> Saucexages.Sauce.sauce_version()
"00"