Skip to main content

ContractValue

Struct ContractValue 

Source
pub struct ContractValue { /* private fields */ }
Expand description

A transport-neutral contract value with an invariant-preserving private representation.

All floating-point values are finite, so structural equality is reflexive in practice. IEEE equality still treats 0.0 and -0.0 as equal.

Implementations§

Source§

impl ContractValue

Source

pub fn null() -> Self

Constructs a null value.

Source

pub fn bool(value: bool) -> Self

Constructs a boolean value.

Source

pub fn i64(value: i64) -> Self

Constructs a signed 64-bit integer value.

Source

pub fn u64(value: u64) -> Self

Constructs an unsigned 64-bit integer value.

Source

pub fn f32(value: f32) -> Result<Self, ValueError>

Constructs a finite 32-bit floating-point value.

Source

pub fn f64(value: f64) -> Result<Self, ValueError>

Constructs a finite 64-bit floating-point value.

Source

pub fn string(value: impl Into<String>) -> Self

Constructs a UTF-8 string value.

Source

pub fn bytes(value: impl Into<Vec<u8>>) -> Self

Constructs a byte string value.

Source

pub fn list(items: impl IntoIterator<Item = ContractValue>) -> Self

Constructs a list. Only contract values can be nested, so Missing cannot appear inside a list.

use boxology_contract::{ContractValue, SlotValue};
let _ = ContractValue::list([SlotValue::Missing]);
Source

pub fn object( entries: impl IntoIterator<Item = (String, ContractValue)>, ) -> Result<Self, ValueError>

Constructs an insertion-ordered object with unique keys. Object values cannot be Missing because they are contract values rather than slots.

use boxology_contract::{ContractValue, SlotValue};
let _ = ContractValue::object([("key".into(), SlotValue::Missing)]);
Source

pub fn enum_value(tag: impl Into<String>, payload: SlotValue) -> Self

Constructs an enum node. A missing payload is legal at this call-slot boundary.

Source

pub fn opaque(payload: OpaquePayload) -> Self

Constructs an opaque transport-neutral value.

Source

pub fn sensitive(inner: ContractValue) -> Self

Marks an entire value subtree as sensitive for diagnostic redaction.

Source

pub fn view(&self) -> ValueRef<'_>

Borrows this value through its read-only semantic view.

Trait Implementations§

Source§

impl Clone for ContractValue

Source§

fn clone(&self) -> ContractValue

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 Debug for ContractValue

Source§

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

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

impl PartialEq for ContractValue

Source§

fn eq(&self, other: &ContractValue) -> 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 ContractValue

Auto Trait Implementations§

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.