Skip to main content

SmlValue

Enum SmlValue 

Source
pub enum SmlValue<'a> {
    Bool(bool),
    Bytes(&'a [u8]),
    Int(i64),
    Uint(u64),
    Time(Time),
}
Expand description

The value of a list entry: SML_Value.

Variants§

§

Bool(bool)

A boolean.

§

Bytes(&'a [u8])

A byte string: identifiers, text, signatures.

§

Int(i64)

A signed integer.

§

Uint(u64)

An unsigned integer.

§

Time(Time)

A point in time (SML_ListType, choice smlTime).

Implementations§

Source§

impl<'a> SmlValue<'a>

Source

pub fn as_integer(&self) -> Option<i128>

The exact integer of an Int or Uint; None for every other kind. Every i64 and u64 fits an i128, so nothing is truncated or re-signed.

use sml_kit::SmlValue;

assert_eq!(SmlValue::Uint(u64::MAX).as_integer(), Some(18_446_744_073_709_551_615));
assert_eq!(SmlValue::Int(-5).as_integer(), Some(-5));
assert_eq!(SmlValue::Bytes(b"ISK").as_integer(), None);
Source

pub fn write(&self, w: &mut Writer<'_>) -> Result<()>

Write the value: integers in the smallest of 1, 2, 4 or 8 bytes.

Trait Implementations§

Source§

impl<'a> Clone for SmlValue<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for SmlValue<'a>

Source§

impl<'a> Debug for SmlValue<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for SmlValue<'a>

Source§

impl<'a> Hash for SmlValue<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for SmlValue<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for SmlValue<'a>

Auto Trait Implementations§

§

impl<'a> Forget for SmlValue<'a>

§

impl<'a> Freeze for SmlValue<'a>
where &'a [u8]: Freeze,

§

impl<'a> Move for SmlValue<'a>

§

impl<'a> RefUnwindSafe for SmlValue<'a>

§

impl<'a> Send for SmlValue<'a>
where &'a [u8]: Send,

§

impl<'a> Sync for SmlValue<'a>

§

impl<'a> Unpin for SmlValue<'a>
where &'a [u8]: Unpin,

§

impl<'a> UnsafeUnpin for SmlValue<'a>
where &'a [u8]: UnsafeUnpin,

§

impl<'a> UnwindSafe for SmlValue<'a>
where &'a [u8]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.