Skip to main content

Mark

Enum Mark 

Source
pub enum Mark {
Show 15 variants Long, Int, Short, Char, Float, Double, Bytes(usize), Str(usize), Object(usize), Enum(Box<Mark>), Null, Array(usize, Box<Mark>), List(usize), Dict(usize, Box<Mark>, Box<Mark>), Map(usize),
}
Expand description

An indicator of what’s contained in the value.

This is the first thing that is read/written in mbon, and it will tell the reader how to read the value that the mark represents.

Variants§

§

Long

§

Int

§

Short

§

Char

§

Float

§

Double

§

Bytes(usize)

§

Str(usize)

§

Object(usize)

§

Enum(Box<Mark>)

§

Null

§

Array(usize, Box<Mark>)

§

List(usize)

§

Dict(usize, Box<Mark>, Box<Mark>)

§

Map(usize)

Implementations§

Source§

impl Mark

Source

pub fn mark_size(&self) -> usize

Get the size in bytes that the mark will use in binary form

use mbon::data::Mark;

assert_eq!(Mark::Int.mark_size(), 1);
Source

pub fn data_size(&self) -> usize

Get the size in bytes that the data will use in binary form

use mbon::data::Mark;

assert_eq!(Mark::Int.data_size(), 4);
Source

pub fn size(&self) -> usize

Get the total size in bytes that this value uses in binary form

use mbon::data::Mark;

assert_eq!(Mark::Int.size(), 5);
Source

pub fn get_type(&self) -> Type

Get the type of this mark

Source

pub fn from_value(val: impl AsRef<Value>) -> Self

Get the mark from a value

use mbon::data::{Mark, Value};

assert_eq!(Mark::from_value(Value::Int(32)), Mark::Int);
assert_eq!(
    Mark::from_value(Value::Str("Hello".to_owned())),
    Mark::Str(5)
);

Trait Implementations§

Source§

impl AsRef<Mark> for Mark

Source§

fn as_ref(&self) -> &Mark

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Mark

Source§

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

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

impl Eq for Mark

Source§

impl<'t> From<&'t Mark> for Type

Source§

fn from(m: &'t Mark) -> Self

Converts to this type from the input type.
Source§

impl<'t> From<&'t Value> for Mark

Source§

fn from(v: &'t Value) -> Self

Converts to this type from the input type.
Source§

impl From<Mark> for Type

Source§

fn from(m: Mark) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for Mark

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Mark

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Mark

Auto Trait Implementations§

§

impl Freeze for Mark

§

impl RefUnwindSafe for Mark

§

impl Send for Mark

§

impl Sync for Mark

§

impl Unpin for Mark

§

impl UnsafeUnpin for Mark

§

impl UnwindSafe for Mark

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.