pub struct Hex { /* private fields */ }
Implementations
sourceimpl Hex
impl Hex
pub fn empty() -> Self
sourcepub fn from_string(d: String) -> Self
pub fn from_string(d: String) -> Self
From STRING.
sourcepub fn to_bool(&self) -> Result<bool>
pub fn to_bool(&self) -> Result<bool>
Turn it into bool
.
use sodg::hex::Hex;
let d = Hex::from_vec([0x01].to_vec());
assert_eq!(true, d.to_bool().unwrap());
sourcepub fn to_i64(&self) -> Result<i64>
pub fn to_i64(&self) -> Result<i64>
Turn it into i64
.
use sodg::hex::Hex;
let d = Hex::from_vec([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A].to_vec());
assert_eq!(42, d.to_i64().unwrap());
sourcepub fn to_f64(&self) -> Result<f64>
pub fn to_f64(&self) -> Result<f64>
Turn it into f64
.
use sodg::hex::Hex;
let d = Hex::from_vec([0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18].to_vec());
assert_eq!(std::f64::consts::PI, d.to_f64().unwrap());
sourcepub fn to_string(&self) -> Result<String>
pub fn to_string(&self) -> Result<String>
Turn it into string
.
use sodg::hex::Hex;
let d = Hex::from_vec([0x41, 0x42].to_vec());
assert_eq!("AB", d.to_string().unwrap());
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Hex
impl<'de> Deserialize<'de> for Hex
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Hex
impl Send for Hex
impl Sync for Hex
impl Unpin for Hex
impl UnwindSafe for Hex
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more