pub struct HostValue { /* private fields */ }Expand description
A locally canonical tagged HostValue.
This type serializes as the portable tagged JSON ABI, but deliberately does
not implement Deserialize. JSON callers must use
HostValue::from_json_with_limits, which decodes a private raw DTO and
checks locally canonical scalar encodings before exposing this value.
Every value carries its own measured extent, so the container constructors can
reject an over-deep or over-large value in constant time per level. That
bound is what makes the recursive operations on this type safe: Drop,
Clone, PartialEq, Debug, and Serialize all recurse once per level,
and all of them abort the process on a value deep enough to exhaust the
stack. Bounding construction is the only chokepoint that covers all five,
so there is deliberately no way to obtain a HostValue whose depth was
never checked against a caller-supplied limit.
Implementations§
Source§impl HostValue
impl HostValue
pub fn from_json_with_limits( input: &str, limits: &Limits, ) -> Result<Self, HostValueJsonError>
pub fn from_json_with_context( input: &str, context: &RuntimeContext, ) -> Result<Self, HostValueJsonError>
pub fn null() -> Self
pub fn boolean(value: bool) -> Self
pub fn nat(value: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn int(value: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn nat8(value: u8) -> Self
pub fn nat16(value: u16) -> Self
pub fn nat32(value: u32) -> Self
pub fn nat64(value: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn int8(value: i8) -> Self
pub fn int16(value: i16) -> Self
pub fn int32(value: i32) -> Self
pub fn int64(value: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn float32(bits: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn float64(bits: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn text(value: impl Into<String>) -> Self
pub fn reserved() -> Self
pub fn principal(value: impl Into<String>) -> Result<Self, HostValueJsonError>
Sourcepub fn opt(
value: Option<Self>,
limits: &Limits,
) -> Result<Self, HostValueJsonError>
pub fn opt( value: Option<Self>, limits: &Limits, ) -> Result<Self, HostValueJsonError>
Wrap a value in an opt, failing closed past limits.max_value_depth
or limits.max_value_elements.
Container construction is fallible because every recursive operation on
the result — including Drop, Clone, and Debug, none of which can
signal failure — walks one stack frame per level. Refusing to build the
value is the only point at which a policy can still be applied.
Sourcepub fn vector(
values: Vec<Self>,
limits: &Limits,
) -> Result<Self, HostValueJsonError>
pub fn vector( values: Vec<Self>, limits: &Limits, ) -> Result<Self, HostValueJsonError>
Build a vec, failing closed past limits.max_value_depth or
limits.max_value_elements.
Sourcepub fn record(
fields: Vec<HostFieldValue>,
limits: &Limits,
) -> Result<Self, HostValueJsonError>
pub fn record( fields: Vec<HostFieldValue>, limits: &Limits, ) -> Result<Self, HostValueJsonError>
Build a record, failing closed past limits.max_value_depth or
limits.max_value_elements.
This does not check for duplicate field IDs or agreement with any
Contract type; that remains validate_host_value’s contract-directed
job.
Sourcepub fn variant(
id: u32,
value: Self,
limits: &Limits,
) -> Result<Self, HostValueJsonError>
pub fn variant( id: u32, value: Self, limits: &Limits, ) -> Result<Self, HostValueJsonError>
Build a variant, failing closed past limits.max_value_depth or
limits.max_value_elements.
pub fn service(principal: impl Into<String>) -> Result<Self, HostValueJsonError>
pub fn func( principal: impl Into<String>, method: impl Into<String>, ) -> Result<Self, HostValueJsonError>
Trait Implementations§
impl Eq for HostValue
impl StructuralPartialEq for HostValue
Auto Trait Implementations§
impl Freeze for HostValue
impl RefUnwindSafe for HostValue
impl Send for HostValue
impl Sync for HostValue
impl Unpin for HostValue
impl UnsafeUnpin for HostValue
impl UnwindSafe for HostValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.