pub trait JsValueExtension {
// Required methods
fn try_as_u8(&self) -> Result<u8, Error>;
fn try_as_u16(&self) -> Result<u16, Error>;
fn try_as_u32(&self) -> Result<u32, Error>;
fn try_as_u64(&self) -> Result<u64, Error>;
fn try_as_vec_u8(&self) -> Result<Vec<u8>, Error>;
}Expand description
Extension trait converting a JsValue into native Rust integer and byte types.
Required Methods§
Sourcefn try_as_u8(&self) -> Result<u8, Error>
fn try_as_u8(&self) -> Result<u8, Error>
Convert the value to a u8, erroring if it is not a number or is out of range.
Sourcefn try_as_u16(&self) -> Result<u16, Error>
fn try_as_u16(&self) -> Result<u16, Error>
Convert the value to a u16, erroring if it is not a number or is out of range.
Sourcefn try_as_u32(&self) -> Result<u32, Error>
fn try_as_u32(&self) -> Result<u32, Error>
Convert the value to a u32, erroring if it is not a number or is out of range.
Sourcefn try_as_u64(&self) -> Result<u64, Error>
fn try_as_u64(&self) -> Result<u64, Error>
Convert the value to a u64, accepting a hex string, a BigInt, or a number.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".