Vint

Trait Vint 

Source
pub trait Vint: Into<u64> + Copy {
    // Provided methods
    fn as_vint(self) -> Result<Vec<u8>, ToolError> { ... }
    fn as_vint_with_length<const LENGTH: usize>(
        &self,
    ) -> Result<[u8; LENGTH], ToolError> { ... }
}
Expand description

Trait to enable easy serialization to a vint.

This is only available for types that can be cast as u64.

Provided Methods§

Source

fn as_vint(self) -> Result<Vec<u8>, ToolError>

Returns a representation of the current value as a vint array.

§Errors

This can return an error if the value is too large to be representable as a vint.

Source

fn as_vint_with_length<const LENGTH: usize>( &self, ) -> Result<[u8; LENGTH], ToolError>

Returns a representation of the current value as a vint array with a specified length.

§Errors

This can return an error if the value is too large to be representable as a vint.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Vint for u8

Source§

impl Vint for u16

Source§

impl Vint for u32

Source§

impl Vint for u64

Implementors§