BytesInDisplayOrder

Trait BytesInDisplayOrder 

Source
pub trait BytesInDisplayOrder<const SHOULD_REVERSE_BYTES_IN_DISPLAY_ORDER: bool = false, const BYTE_LEN: usize = 32>: Sized {
    // Required methods
    fn bytes_in_serialized_order(&self) -> [u8; BYTE_LEN];
    fn from_bytes_in_serialized_order(bytes: [u8; BYTE_LEN]) -> Self;

    // Provided methods
    fn bytes_in_display_order(&self) -> [u8; BYTE_LEN] { ... }
    fn from_bytes_in_display_order(
        bytes_in_display_order: &[u8; BYTE_LEN],
    ) -> Self { ... }
}
Expand description

This trait provides methods to access and construct types from their internal serialized byte order (typically little-endian) as well as their big-endian byte order used for display and RPC.

Zebra displays transaction and block hashes in big-endian byte-order, following the u256 convention set by Bitcoin and zcashd.

Required Methods§

Source

fn bytes_in_serialized_order(&self) -> [u8; BYTE_LEN]

Returns the bytes in the internal serialized order.

Source

fn from_bytes_in_serialized_order(bytes: [u8; BYTE_LEN]) -> Self

Creates an instance from bytes in the internal serialized order.

Provided Methods§

Source

fn bytes_in_display_order(&self) -> [u8; BYTE_LEN]

Return the bytes in big-endian byte-order suitable for printing out byte by byte.

Source

fn from_bytes_in_display_order(bytes_in_display_order: &[u8; BYTE_LEN]) -> Self

Convert bytes in big-endian byte-order into big-endian display order.

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.

Implementors§