Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Null,
    Number(f64),
    Text(Arc<str>),
    Bytes(Arc<Vec<u8>>),
    List(Arc<Vec<Value>>),
    Opaque(Arc<dyn Any + Send + Sync>),
    Map(Arc<Vec<(String, Value)>>),
}
Expand description

A datum crossing from one node to the next.

Arc wherever the data is heavy, because a value is cloned on every edge and cloning must not copy.

Variants§

§

Null

Nothing. What a root node receives when you pass it no input.

§

Number(f64)

A number.

§

Text(Arc<str>)

UTF-8 text.

§

Bytes(Arc<Vec<u8>>)

Uninterpreted bytes.

§

List(Arc<Vec<Value>>)

Several values in order.

§

Opaque(Arc<dyn Any + Send + Sync>)

Something the core carries without looking at it, as dyn Any so the core need not depend on PyO3.

It only exists in this process and in this run, and everything else follows: no content hash, no serialization, and no comparison but identity.

§

Map(Arc<Vec<(String, Value)>>)

Several named values: what a node with several incoming edges receives, keyed by the node that produced each one.

Ordered, in the edges’ declaration order: a HashMap iterates differently in each process, so a content hash would be useless.

Implementations§

Source§

impl Value

Source

pub fn number(x: f64) -> Self

A number.

Source

pub fn text(s: impl AsRef<str>) -> Self

Text.

Source

pub fn list(values: impl Into<Vec<Value>>) -> Self

A list.

Source

pub fn map(pairs: impl Into<Vec<(String, Value)>>) -> Self

A map, in the order you pass the pairs.

Source

pub fn get(&self, key: &str) -> Option<&Value>

The value stored under that key, if this is a map and has it.

Source

pub fn values(&self) -> Option<Vec<&Value>>

A map’s values, in order — flattening a map to a list is this.

Source

pub fn opaque(x: impl Any + Send + Sync) -> Self

Wraps something so it crosses the graph untouched.

Source

pub fn downcast<T: Any + Send + Sync>(&self) -> Option<&T>

What is inside an opaque, if it is of this type.

Source

pub fn travels(&self) -> bool

Whether this value, and everything inside it, can leave this process.

false for an Opaque at any depth: what it carries only exists here. Whoever is about to send it asks first, so the refusal names the reason instead of coming out of a serializer.

Source

pub fn type_name(&self) -> &'static str

What to call this variant in an error message.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl<'de> Deserialize<'de> for Value

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&str> for Value

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(x: f64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

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

Two opaques are equal only if they are the same one: the core cannot compare contents it does not look at.

1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Value

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

§Errors

If anything inside only exists in this process. Ask travels first and the refusal reads better.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl !UnwindSafe for Value

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 = 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,