A (Try)FromBytes
#[length]
field attribute
#1328
Labels
customer-request
Documents customer requests.
(Try)FromBytes
#[length]
field attribute
#1328
Uh oh!
There was an error while loading. Please reload this page.
See also: #5 (comment)
Addresses #1289. Discussion of alternative solutions should occur there, or in their own issues.
Many formats include a
length
field in their header that describes the length of a variable-sized body; e.g., UDP:Such types are inconvenient to correctly parse in zerocopy; the
length
must first be parsed, and only thenFromBytes::try_ref_from_prefix_with_elems
can be invoked with thatlength
. Alternatively, the entire buffer can be parsed withtry_ref_from_prefix
, and then truncated thereafter. These approaches are inconvenient.We could potentially simplify this with a
#[length]
field attribute; e.g.:...such that
FromBytes::ref_from_prefix
would respect thelength
attribute.Some considerations:
TryFromBytes
, where excess data might be invalidlength
is factored into a different, fixed-sized header type?The text was updated successfully, but these errors were encountered: