Trait Conversion

Source
pub trait Conversion<T>
where Self: Sized,
{ type Error; // Required methods fn from_bits(bits: T) -> Self; fn from_hex(hex_str: &str) -> Self; fn try_from_bits(bits: T) -> Result<Self, Self::Error>; fn try_from_hex(hex_str: &str) -> Result<Self, Self::Error>; fn into_bits(self) -> T; fn into_hex(self) -> String; }
Expand description

A trait for types that can be converted to and from bitfield representations (bits) of integers and hexadecimal string slices (hex).

§alloc features:
  • into_hex

Required Associated Types§

Required Methods§

Source

fn from_bits(bits: T) -> Self

Convert an integer of type T into Self

Source

fn from_hex(hex_str: &str) -> Self

Convert a hexadecimal string slice into Self

Source

fn try_from_bits(bits: T) -> Result<Self, Self::Error>

Convert an integer of type T into Self

§Errors
  • Implementation dependent
Source

fn try_from_hex(hex_str: &str) -> Result<Self, Self::Error>

Convert a hexadecimal string slice into Self

§Errors
  • Implementation dependent
Source

fn into_bits(self) -> T

Convert self into an integer of type T

Source

fn into_hex(self) -> String

Convert self into a hexadecimal string

§Requires
  • alloc

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§