API Reference
*************
.. current-library:: binary-data
.. current-module:: binary-data
Overview
========
This describes the API available from binary-data. It is organized in
the following sections, depending on different demands: using binary
data in a tool, extending with a custom binary format, and the
internal API.
Class hierarchy
===============
The class hierarchy is rooted in `` ``. Several direct
subclasses exist, some are ``open`` and may be subclassed. Only those
combinations of direct subclasses which were needed until now are
defined (there might be need for other combinations in the future).
.. class::
:abstract:
:description:
The abstract superclass of all frames, several generic functions
are defined on this class.
:superclasses: :drm:``
:operations:
- :gf:`parse-frame`
- :gf:`assemble-frame`
- :gf:`summary`
.. class::
:abstract:
:description:
The abstract superclass of all frames without any further structure.
:superclasses: :class:` `
:operations:
- :gf:`read-frame`
.. class::
:abstract:
:description:
The abstract superclass of all frames with a static length. The
specialization of :gf:`frame-size` calls :gf:`field-size` on the
object class of the given instance.
:superclasses: :class:` `
.. class::
:abstract:
:description:
The abstract superclass of all frames with a variable length.
:superclasses: :class:` `
.. class::
:abstract:
:description:
The abstract superclass of all frames with a conversion into a
native Dylan type.
:superclasses: :class:` `
.. class::
:abstract:
:description:
Abstract superclass of all frames with a custom class instance.
:superclasses: :class:` `
.. class::
:abstract:
:description:
Abstract superclass for fixed sized frames without a translation
:superclasses: :class:``, :class:``
.. class::
:abstract:
:description:
Abstract superclass for variable sized frames without a
translation. This is the direct superclass of
:class:``.
:superclasses: :class:``, :class:``
.. class::
:abstract:
:open:
:description:
Superclass of all fixed size leaf frames with a translation,
mainly used for bit vectors represented as Dylan :drm:``
:superclasses: :class:``, :class:``, :class:``
.. class::
:abstract:
:open:
:description:
Superclass of all variable size leaf frames with a translation
(currently unused)
:superclasses: :class:``, :class:``, :class:``
.. class::
:abstract:
:open:
:description:
Superclass of all fixed size leaf frames without a translation,
mainly used for byte vectors (IP addresses, MAC address, ...),
see its subclass :class:``.
:superclasses: :class:``, :class:``
.. class::
:abstract:
:open:
:description:
Superclass of all variable size leaf frames without a
translation (for example class :class:`` and class
:class:``)
:superclasses: :class:``, :class:``
.. class::
:description:
A concrete zero size leaf frame without a translation. This frame type
can be used as one of the types of a variably-typed field to make the
field optional. A field with a type is considered to be
missing from the container frame. Conversion of a to string
or vice versa is not supported (because it wouldn't make much sense).
:superclasses: :class:``
.. class::
:abstract:
:open:
Superclass of all binary data definitions using the :macro:`define
binary-data` macro.
:superclasses: :class:``
:operations:
- :gf:`frame-name`
- :gf:`fields`
- :gf:`field-count`
- :gf:`packet`
.. class::
:open:
:abstract:
Superclass of all binary data definitions which support layering,
thus have a header and payload.
:superclasses: :class:``
:description:
The method :gf:`payload` projects the payload of the header
frame. The method :gf:`payload-setter` is also defined. The
specialized method :gf:`fixup!` calls :gf:`fixup!` on the
payload of the header frame instance.
:operations:
- :gf:`payload`
- :gf:`payload-setter`
- :gf:`fixup!`
.. class::
:open:
:abstract:
Superclass of all binary data definitions which have an abstract
header followed by more fields. In the header a specific
:class:`` determines which subclass to instantiate.
:superclasses: :class:``
Tool API
========
Parsing Frames
--------------
.. generic-function:: parse-frame
:open:
Parses the given binary packet as frame-type, resulting in an
instance of the frame-type and the number of consumed bits.
:signature: parse-frame *frame-type* *packet* #rest *rest* #key #all-keys => *result* *consumed-bits*
:parameter frame-type: Any subclass of `` ``.
:parameter packet: The byte vector as ````.
:parameter #rest rest: An instance of ````.
:value result: An instance of the given frame-type.
:value consumed-bits: The number of bits consumed as ````
.. generic-function:: read-frame
:open:
Converts a given string to an instance of the given leaf frame type.
:signature: read-frame *frame-type* *string* => *frame*
:parameter frame-type: An instance of ``subclass()``.
:parameter string: An instance of ````.
:value frame: An instance of ````.
Assembling Frames
-----------------
.. generic-function:: assemble-frame
Produces a binary vector representing this frame. All field fixup
functions are called.
:signature: assemble-frame *frame* => *packet*
:parameter frame: An instance of :class:` `.
:value packet: An instance of ````.
Information about Frames
------------------------
.. generic-function:: frame-size
:open:
Returns the length in bits for the given frame.
:signature: frame-size *frame* => *length*
:parameter frame: An instance of `` ``.
:value length: The size in bits, an instance of ````.
.. generic-function:: summary
:open:
Returns a human-readable customizable (in binary-data-definer)
string, which summarizes the frame.
:signature: summary *frame* => *summary*
:parameter frame: An instance of :class:` `.
:value summary: An instance of :drm:``.
.. generic-function:: packet
:open:
Underlying byte vector of the given :class:``.
:signature: packet *frame* => *byte-vector*
:parameter frame: An instance of :class:``.
:value byte-vector: An instance of :class:``.
.. generic-function:: parent
:sealed:
If the frame is a payload of another layer, returns the frame of
the upper layer, false otherwise.
:signature: parent *frame* => *parent-frame*
:parameter frame: An instance of :class:`` or :class:``
:value parent-frame: Either the :class:`` of the upper layer or ``#f``
Information about Frame Types
-----------------------------
.. generic-function:: fields
:open:
Returns a vector of :class:`` for the given :class:``
:signature: fields *frame-type* => *fields*
:parameter frame-type: Any subclass of :class:``.
:value fields: A :drm:`` containing all fields.
.. note:: Current API also allows instances of ````, should be revised
.. generic-function:: frame-name
:open:
Returns the name of the frame type.
:signature: frame-name *frame-type* => *name*
:parameter frame-type: Any subclass of :class:``.
:value name: A :drm:`` with the human-readable frame name.
.. note:: Current API also allows instances of ````, should be revised
Fields
------
Syntactic sugar in the :macro:`define binary-data` domain-specific
language instantiates these fields.
.. class::
:abstract:
The abstract superclass of all fields.
:superclasses: :drm:``
:keyword name: The name of this field.
:keyword fixup: A unary Dylan function computing the value of this field, used if no default is supplied and none provided by the client, defaults to ``#f``.
:keyword init-value: The default value if the client did not provide any, default `$unsupplied `_.
:keyword static-end: A Dylan expression determining the end, defaults to :const:`$unknown-at-compile-time`.
:keyword static-length: A Dylan expression determining the length, defaults to :const:`$unknown-at-compile-time`.
:keyword static-start: A Dylan expression determining the start, defaults to :const:`$unknown-at-compile-time`.
:keyword dynamic-end: A unary Dylan function computing the end, defaults to ``#f``.
:keyword dynamic-length: A unary Dylan function computing the length, defaults to ``#f``.
:keyword dynamic-start: A unary Dylan function computing the start, defaults to ``#f``.
:keyword getter: The getter method to extract this fields value out of a concrete frame.
:keyword setter: The setter method to set this fields to a concrete value in a concrete frame.
:keyword index: An :drm:`` which is an index of this field in its :class:``.
:description:
All keyword arguments correspond to a slot, which can be
accessed.
:operations:
- :meth:`field-name()`
- :meth:`fixup-function()`
- :meth:`init-value()`
- :meth:`static-start()`
- :meth:`static-length()`
- :meth:`static-end()`
- :meth:`getter()`
- :meth:`setter()`
See also
* :macro:`define binary-data`
* :gf:`fields`
.. class::
The class for fields of dynamic type.
:superclasses: :class:``
:keyword type-function: A unary Dylan function computing the type of the field, defaults to :func:`payload-type`.
See also
* :func:`payload-type`
* :gf:`lookup-layer`
* :gf:`reverse-lookup-layer`
.. class::
:abstract:
The abstract superclass of all statically typed fields.
:superclasses: :class:``
:keyword type: The static type, a subclass of :class:` `.
:operations:
- :meth:`type()`
.. note:: restrict type in source code!
.. class::
The common field. Nothing interesting going on here.
:superclasses: :class:``
.. class::
An enumeration field to map :drm:`` to :drm:``.
:superclasses: :class:``
:keyword mapping: A mapping from keys to values as :drm:``.
.. class::
The layering field is used in :class:`` and
:class:`` to determine the concrete
type of the payload or which subclass to use.
:superclasses: :class:``
:description:
The ``fixup-function`` slot is bound to use the available layering
information. No need to specify a fixup.
.. class::
:abstract:
Abstract superclass of repeated fields. The ``init-value`` slot is
bound to ``#()``.
:superclasses: :class:``
.. class::
A repeated field whose number of repetitions is determined
externally.
:superclasses: :class:``
:keyword count: A unary function returning the number of occurences.
.. class::
A repeated field whose end is determined internally.
:superclasses: :class:``
:keyword reached-end?: A unary function returning a :drm:``.
Layering of frames
------------------
.. function:: payload-type
The type of the payload, It is just a wrapper around
:gf:`lookup-layer`, which returns :class:`` if
``lookup-layer`` returned false.
:signature: payload-type *frame* => *payload-type*
:parameter frame: An instance of :class:``.
:value payload-type: An instance of ````.
.. generic-function:: lookup-layer
:open:
Given a *frame-type* and a *key*, returns the type of the payload.
:signature: lookup-layer *frame-type* *key* => *payload-type*
:parameter frame-type: Any subclass of :class:` `.
:parameter key: Any :drm:``.
:value payload-type: The resulting type, an instance of ``false-or()``.
.. generic-function:: reverse-lookup-layer
:open:
Given a frame type and a payload, returns the value for the layering field.
:signature: reverse-lookup-layer *frame-type* *payload* => *layering-value*
:parameter frame-type: Any subclass of :class:` `.
:parameter payload: Any :class:` ` instance.
:value value: The returned layering field value, an :drm:``.
.. note:: Check whether it can work with other types than integers
Database of Binary Data Formats
-------------------------------
.. note:: Rename to ``$binary-data-registry`` or similar. Also, narrow types for the functions in this section.
.. constant:: $protocols
A hash table with all defined binary formats. Insertion is done by
a call of :macro:`define binary-data`.
:type: :drm:``
:value: Mapping of :drm:`` to subclasses of :class:``.
.. function:: find-protocol
Looks for the given name in the hashtable
:const:`$protocols`. Signals an error if no protocol with the given
name can be found.
:signature: find-protocol *frame-name* => *frame-type* *frame-name*
:parameter frame-name: An instance of :drm:``.
:value frame-type: The frame type for the requested frame name, an instance of :drm:``.
:value frame-name: The name under which the frame is known in the registry, an instance of :drm:``.
.. function:: find-protocol-field
Queries a field by name in a given binary data format. Errors if no
such field is known in the binary data format.
:signature: find-protocol-field *frame-type* *field-name* => *field*
:parameter frame-type: The type of a frame, an instance of :drm:``.
:parameter field-name: The name of a field, an instance of :drm:``.
:value field: An instance of :class:``.
Utilities
---------
.. generic-function:: hexdump
Prints the given *data* in hexadecimal on the given *stream*.
:signature: hexdump *stream* *data* => ()
:parameter stream: An instance of ````.
:parameter data: An instance of ````.
:description:
Prints 8 bytes separated by a whitespace in hexadecimal,
followed by two whitespaces, and another 8 bytes.
If the given *data* has more than 16 elements, it prints
multiple lines, and prefix each with a line number (as 16 bit
hexadecimal).
.. function:: byte-offset
Computes the number of bytes for a given number of bits. A synonym
for ``rcurry(ash, 3)``.
:signature: byte-offset *bits* => *bytes*
:parameter bits: An :drm:``.
:value bytes: An :drm:``.
.. function:: bit-offset
Computes the number of bits which do not fit into a byte for a
given number of bits. A synonym for ``curry(logand, 7)``.
:signature: bit-offset *bits* => *bits-not-in-byte*
:parameter bits: An :drm:``.
:value bits-not-in-byte: An :drm:`` between 0 and 7.
.. function:: byte-aligned
Checks that the given number of bits can be represented in full
bytes, otherwise signals an :class:``.
:signature: byte-aligned *bits*
:parameter bits: An instance of ````.
.. generic-function:: data
Returns the underlying byte vector of a wrapper object, used for
several untranslated leaf frames.
:signature: data (object) => (#rest results)
:parameter object: An instance of ````.
:value #rest results: An instance of ````.
.. note:: should be removed from the API, or become internal
Errors
------
.. class::
:superclasses: :drm:``
.. class::
:superclasses: :drm:``
.. class::
:superclasses: :drm:``
.. class::
:superclasses: :drm:``
.. class::
:superclasses: :drm:``
.. class::
:superclasses: :drm:``
Extension API
=============
Extending Binary Data Formats
-----------------------------
This domain-specific language defines a subclass of
:class:``, and lots of boilerplate.
.. macro:: define binary-data
:defining:
:macrocall:
.. code-block:: dylan
define [abstract] binary-data *binary-format-name* ([*super-binary-format*])
[summary *summary*] [;]
[over *over-spec* *] [;]
[length *length-expression*] [;]
[*field-spec*] [;]
end
:parameter binary-format-name: A standard Dylan class name.
:parameter super-binary-format: A standard Dylan name, used superclass.
:parameter summary: A Dylan expression consisting of a format-string and a list of arguments.
:parameter over-spec: A pair of binary format and value.
:parameter length-expression: A Dylan expression computing the length of a frame instance.
:parameter field-spec: A list of fields for this binary format.
:description:
Defines the binary data class *binary-data-name*, which is a
subclass of *super-binary-format*. In the body some syntactic
sugar for specializing the pretty printer (*summary* specializes
:gf:`summary`), providing a custom length implementation
(*length* specializes :gf:`container-frame-size`), and provide
binary format layering information via *over-spec*
(:class:``). The remaining body is a list of
*field-spec*. Each *field-spec* line corresponds to a slot in
the defined class. Additionally, each *field-spec* instantiates
an object of :class:`` to store the static metadata. The
vector of fields is available via the method :gf:`fields`.
.. code-block:: dylan
summary: *format-string* *format-arguments*
This generates a method implementation for :gf:`summary`. Each
*format-arguments* is applied to the frame instance.
.. code-block:: dylan
over-spec: *over-binary-format* *layering-value*
The *over-binary-format* should be a subclass of
:class:`` or
:class:``. The *layering-value*
will be registered for the specified *over-binary-format*.
.. code-block:: dylan
field-spec: [*field-attribute*] field *field-name* [:: *field-type*] [= *default-value*], [*keyword-arguments* *] [;]
field-attribute: variably-typed | layering | repeated | enum
mapping: { *key* <=> *value* }
* *field-name*: Each field has a unique *field-name*, which is used as name for the getter and setter methods
* *field-type*: The *field-type* can be any subclass of :class:` `, required unless ``variably-typed`` attribute provided.
* *default-value*: The *default-value* should be an instance of the given *field-type*.
* *field-attribute*: Syntactic sugar for some common patterns is available via attributes.
- ``variably-typed`` instantiates a :class:``.
- ``layering`` instantiates a :class:``.
- ``repeated`` instantiates a :class:``.
- ``enum`` instantiates a :class:``.
* *keyword-arguments*: Depending on the field type, various keywords are supported. Lots of values are standard Dylan expressions, where the current frame object is implicitly bound to ``frame``, indicated by *frame-expression*.
- fixup: A *frame-expression* computing the field value if no default was supplied, and the client didn't provide one (handy for length fields).
- start: A *frame-expression* computing the start bit of the field in the frame.
- end: A *frame-expression* computing the end bit of the field in the frame.
- length: A *frame-expression* computing the length of the field.
- static-start: A Dylan *expression* stating the start of the field in the frame.
- static-end: A Dylan *expression* stating the end of the field in the frame.
- static-length: A Dylan *expression* stating the length of the field.
- type-function: A *frame-expression* computing the type of this :class:``.
- count: A *frame-expression* computing the amount of repetitions of this :class:``.
- reached-end?: A *frame-expression* returning a :drm:`` whether this :class:`` has reached its end.
- mappings: A *mapping* for :class:`` between values and :drm:``
The list of fields is instantiated once for each binary data
definition. If a static start offset, length, and end offset can
be trivially computed (using constant folding), this is done
during macro processing.
Several generic functions can be specialized on the
*binary-format-name* for custom behaviour:
- :gf:`fixup!`
- :gf:`summary`
- :gf:`parse-frame`
.. note:: rename start, end, length to dynamic-start, dynamic-end, dynamic-length
.. note:: Check whether those field attributes compose in some way
.. generic-function:: fixup!
:open:
Fixes data in an assembled container frame.
:signature: fixup! *frame* => ()
:parameter frame: A union of :class:`` and
:class:``. Usually specialized on a
subclass of :class:``.
:description:
Used for post-assembly of certain fields, such as checksum
calculations in IPv4, ICMP, TCP frames, compression of domain
names in DNS fragments.
Defining a Custom Leaf Frame
----------------------------
A common structure in binary data formats are subsequent ranges of
bits or bytes, each with a different meaning. There are some macros
available to define frame types of common patterns.
.. generic-function:: field-size
:open:
Returns the static size of a given frame type. Should be
specialized for custom fixed sized frames.
:signature: field-size *frame* => *length*
:parameter frame: Any subclass of :class:` `.
:value length: The bit size of the frame type :drm:``.
.. generic-function:: high-level-type
:open:
For translated frames, return the native Dylan type. Otherwise
identity.
:signature: high-level-type *frame-type* => *type*
:parameter frame-type: An instance of ``subclass( )``.
:value type: An instance of ````.
.. generic-function:: assemble-frame-into
:open:
Shuffle the bits in the given *packet* so that the *frame* is
encoded correctly.
:signature: assemble-frame-into *frame* *packet* => *length*
:parameter frame: An instance of :class:` `.
:parameter packet: An instance of :class:``.
:value length: An instance of :drm:``.
.. generic-function:: assemble-frame-into-as
:open:
Shuffle the bits in the given *packet* so that the *frame* is
encoded correctly as the given *frame-type*.
:signature: assemble-frame-into-as *frame-type* *frame* *packet* => *length*
:parameter frame-type: A subclass of :class:``.
:parameter frame: An instance of :drm:``.
:parameter packet: An instance of :class:``.
:value length: An instance of :drm:``.
.. macro:: define n-bit-unsigned-integer
:defining:
Describes an :drm:`` represented by a bit vector of
arbitrary size.
:macrocall:
.. code-block:: dylan
define n-bit-unsigned-integer (*class-name* ; *bits* )
end
:parameter class-name: A Dylan class name which is defined by this macro.
:parameter bits: The number of bits represented by this frame.
:description:
Defines the class *class-name* with
:class:`` as its superclass.
There are several predefined classes of the form
```` with *K* between 1 and 15, and 20.
:operations:
- :gf:`high-level-type` returns ``limited(, min: 0, max: 2 ^ bits -1)``.
- :gf:`field-size` returns *bits*.
.. macro:: define n-byte-unsigned-integer
:defining:
Describes an :drm:`` represented by a byte vector of
arbitrary size and encoding (little or big endian).
:macrocall:
.. code-block:: dylan
define n-byte-unsigned-integer (*class-name-prefix* ; *bytes*)
end
:parameter class-name-prefix: A prefix for the class name which is defined by this macro.
:parameter bytes: The number of bytes represented by this frame.
:description:
Defines the classes *class-name-prefix*
``-big-endian-unsigned-integer>`` (superclass
:class:`` and
*class-name-prefix* ``-little-endian-unsigned-integer>``
(superclass :class:``.
The following classes are predefined: ``<2byte-big-endian-unsigned-integer>``,
``<2byte-little-endian-unsigned-integer>``,
``<3byte-big-endian-unsigned-integer>``, and
``<3byte-little-endian-unsigned-integer>``.
:operations:
- :gf:`high-level-type` returns ``limited(, min: 0, max: 2 ^ (8 * *bytes*) - 1``.
- :gf:`field-size` returns *bytes* * 8.
.. macro:: define n-byte-vector
:defining:
Defines a class with an underlying fixed size byte vector.
:macrocall:
.. code-block:: dylan
define n-byte-vector (*class-name* , *bytes*)
end
:parameter class-name: A standard Dylan class name.
:parameter bytes: The number of bytes represented by this frame.
:description:
Defines the class *class-name*, as a subclass of
:class:``. Calls :macro:`define
leaf-frame-constructor` with the given *class-name* (without
surrounding angle brackets).
:operations:
- :gf:`field-size` returns *bytes* * 8.
.. macro:: define leaf-frame-constructor
:defining:
Defines constructors for a given name.
:macrocall:
.. code-block:: dylan
define leaf-frame-constructor (*constructor-name*)
end
:parameter constructor-name: name of the constructor.
:description:
Defines the generic function *constructor-name* and
three specializations:
:operations:
- *constructor-name* :class:`` calls :gf:`parse-frame`
- *constructor-name* :drm:``, converts the ```` into a ```` and calls *constructor-name*.
- *constructor-name* :drm:``, which calls :gf:`read-frame`.
Predefined Leaf Frames
----------------------
.. class::
:abstract:
The superclass of all bit frames, concrete classes are defined with
the :macro:`define n-bit-unsigned-integer`.
:superclasses: :class:``
:operations:
- :drm:`as` :drm:``
- :gf:`assemble-frame`
- :gf:`parse-frame`
- :gf:`read-frame`
See also
* :macro:`define n-bit-unsigned-integer`
.. class::
A single bit, at the Dylan level a :drm:``.
The :gf:`high-level-type` returns :drm:``.
The :gf:`field-size` returns 1.
:superclasses: :class:``
.. class::
A single byte, represented as a `
`_.
:operations:
- :gf:`high-level-type` returns `
https://opendylan.org/library-reference/common-dylan/byte-vector.html#common-dylan:byte-vector:[byte]`_.
- :gf:`field-size` returns 8.
:superclasses: :class:``
.. class::
:abstract:
A byte vector of arbitrary size, provided externally.
:superclasses: :class:``
.. class::
A :drm:`` of a certain length, externally delimited. The
conversion method :drm:`as` is specialised on :drm:`` and
````.
:superclasses: :class:``
.. note:: should be a variable-size translated leaf frame, if that is possible.
.. class::
The bottom of the type hierarchy: if nothing is known, a
```` is all you can have. :gf:`hexdump` can
be used to inspect the frame contents.
:superclasses: :class:``
.. class::
:open:
:abstract:
A vector of any amount of bytes with a custom representation. Used
amongst others for IP addresses, MAC addresses
:superclasses: :class:``
:keyword data: The underlying byte vector.
:operations:
- :drm:`as` :drm:``
- :gf:`assemble-frame`
- :gf:`parse-frame`
- :gf:`read-frame`
See also
* :macro:`define n-byte-vector`
.. class::
:abstract:
A frame representing an :drm:`` of a certain size,
depending on the size of the underlyaing byte vector.
The macro :macro:`define n-byte-unsigned-integer-definer` defines
subclasses with a certain size.
:superclasses: :class:``
:operations:
- :drm:`as` :drm:``
- :gf:`assemble-frame`
- :gf:`parse-frame`
- :gf:`read-frame`
See also
* :macro:`define n-byte-unsigned-integer`
* :class:``
.. class::
:abstract:
A frame representing an :drm:`` of a certain size,
depending on the size of the underlying byte vector.
The macro :macro:`define n-byte-unsigned-integer-definer` defines
subclasses with a certain size.
:superclasses: :class:``
:operations:
- :drm:`as` :drm:``
- :gf:`assemble-frame`
- :gf:`parse-frame`
- :gf:`read-frame`
See also
* :macro:`define n-byte-unsigned-integer`
* :class:``
32 Bit Frames
-------------
The :drm:`` type in Dylan is represented by only 30
bits, thus 32 bit frames which should be represented as a
:drm:`` require a workaround. The workaround consists of using
:class:`` and converting to
:drm:`` values.
.. note:: This hack is awful and should be replaced by native 32 bit integers, or machine words.
.. class::
:superclasses: :class:``
.. class::
:superclasses: :class:``
.. generic-function:: big-endian-unsigned-integer-4byte
:signature: big-endian-unsigned-integer-4byte (data) => (#rest results)
:parameter data: An instance of ````.
:value #rest results: An instance of ````.
.. generic-function:: little-endian-unsigned-integer-4byte
:signature: little-endian-unsigned-integer-4byte (data) => (#rest results)
:parameter data: An instance of ````.
:value #rest results: An instance of ````.
.. function:: byte-vector-to-float-be
:signature: byte-vector-to-float-be (bv) => (res)
:parameter bv: An instance of ````.
:value res: An instance of ````.
.. function:: byte-vector-to-float-le
:signature: byte-vector-to-float-le (bv) => (res)
:parameter bv: An instance of ````.
:value res: An instance of ````.
.. function:: float-to-byte-vector-be
:signature: float-to-byte-vector-be (float) => (res)
:parameter float: An instance of ````.
:value res: An instance of ````.
.. function:: float-to-byte-vector-le
:signature: float-to-byte-vector-le (float) => (res)
:parameter float: An instance of ````.
:value res: An instance of ````.
Stretchy Vector Subsequences
============================
The underlying byte vector which is used in binary data is a
:const:``. To allow zerocopy while parsing, and
providing each frame parser only with a byte vector of the required
size for the type, there is a :class:``
which tracks the byte-vector together with a start and end index.
.. note:: Should live in a separate module and types can be narrowed a bit further.
.. constant::
:type: :drm:``
:value: ``limited(, of: )``
.. class::
:abstract:
:superclasses: :class:``
:keyword data:
:keyword end:
:keyword start:
.. generic-function:: subsequence
:signature: subsequence (seq) => (#rest results)
:parameter seq: An instance of ````.
:value #rest results: An instance of ````.
.. class::
:superclasses: :class:``
.. generic-function:: decode-integer
:signature: decode-integer (seq count) => (#rest results)
:parameter seq: An instance of ````.
:parameter count: An instance of ````.
:value #rest results: An instance of ````.
.. generic-function:: encode-integer
:signature: encode-integer (value seq count) => (#rest results)
:parameter value: An instance of ````.
:parameter seq: An instance of ````.
:parameter count: An instance of ````.
:value #rest results: An instance of ````.