#[derive(FromBytes)]
{
// Attributes available to this derive:
#[nuts_bytes]
}
Expand description
Derive macro implementation of the FromBytes
trait.
This derive macro generates a FromBytes
implementation for struct
and
enum
types. union
types are currently not supported.
ยงAttributes
#[nuts_bytes(map_from_bytes = $path)]
Calls the function $path
on the deserialized value.
The given function must be callable as
fn<S: FromBytes, T, E: Into<Box<dyn std::error::Error + Send + Sync>>(S) -> std::result::Result<T, E>
If the function succeeds, the returned value is assigned to this field. An
error is converted into a Error::Custom
error, where the error (E
) is
attached to the Error::Custom
variant.
#[nuts_bytes(map = $module)]
Combination of map_from_bytes
and map_to_bytes
. The crate will use
$module::from_bytes
as the map_from_bytes
function and
$module::to_bytes
as the map_to_bytes
function.