simd_json::prelude

Trait ValueTryAsScalar

source
pub trait ValueTryAsScalar {
Show 17 methods // Required methods fn try_as_bool(&self) -> Result<bool, TryTypeError>; fn try_as_i128(&self) -> Result<i128, TryTypeError>; fn try_as_i64(&self) -> Result<i64, TryTypeError>; fn try_as_i32(&self) -> Result<i32, TryTypeError>; fn try_as_i16(&self) -> Result<i16, TryTypeError>; fn try_as_i8(&self) -> Result<i8, TryTypeError>; fn try_as_u128(&self) -> Result<u128, TryTypeError>; fn try_as_u64(&self) -> Result<u64, TryTypeError>; fn try_as_usize(&self) -> Result<usize, TryTypeError>; fn try_as_u32(&self) -> Result<u32, TryTypeError>; fn try_as_u16(&self) -> Result<u16, TryTypeError>; fn try_as_u8(&self) -> Result<u8, TryTypeError>; fn try_as_f64(&self) -> Result<f64, TryTypeError>; fn try_cast_f64(&self) -> Result<f64, TryTypeError>; fn try_as_f32(&self) -> Result<f32, TryTypeError>; fn try_as_str(&self) -> Result<&str, TryTypeError>; fn try_as_char(&self) -> Result<char, TryTypeError>;
}
Expand description

try_as_* access to scalar value types

Required Methods§

source

fn try_as_bool(&self) -> Result<bool, TryTypeError>

Tries to represent the value as a bool

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_i128(&self) -> Result<i128, TryTypeError>

Tries to represent the value as a i128

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_i64(&self) -> Result<i64, TryTypeError>

Tries to represent the value as an i64

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_i32(&self) -> Result<i32, TryTypeError>

Tries to represent the value as an i32

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_i16(&self) -> Result<i16, TryTypeError>

Tries to represent the value as an i16

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_i8(&self) -> Result<i8, TryTypeError>

Tries to represent the value as an i8

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_u128(&self) -> Result<u128, TryTypeError>

Tries to represent the value as an u128

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_u64(&self) -> Result<u64, TryTypeError>

Tries to represent the value as an u64

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_usize(&self) -> Result<usize, TryTypeError>

Tries to represent the value as an usize

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_u32(&self) -> Result<u32, TryTypeError>

Tries to represent the value as an u32

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_u16(&self) -> Result<u16, TryTypeError>

Tries to represent the value as an u16

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_u8(&self) -> Result<u8, TryTypeError>

Tries to represent the value as an u8

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_f64(&self) -> Result<f64, TryTypeError>

Tries to represent the value as a f64

§Errors

if the requested type doesn’t match the actual type

source

fn try_cast_f64(&self) -> Result<f64, TryTypeError>

Tries to Casts the current value to a f64 if possible, this will turn integer values into floats and error if it isn’t possible

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_f32(&self) -> Result<f32, TryTypeError>

Tries to represent the value as a f32

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_str(&self) -> Result<&str, TryTypeError>

Tries to represent the value as a &str

§Errors

if the requested type doesn’t match the actual type

source

fn try_as_char(&self) -> Result<char, TryTypeError>

Tries to represent the value as a Char

§Errors

if the requested type doesn’t match the actual type

Implementors§