Struct oc_wasm_safe::descriptor::Decoded [−][src]
pub struct Decoded(_);
Expand description
A CBOR-decoded opaque value descriptor.
A value of this type encapsulates an opaque value descriptor. It cannot be cloned. Dropping it
does nothing; this may cause a resource leak, but resource leaks are not considered unsafe
Rust, and under the circumstances, closing the descriptor could be unsafe (see the safety note
on into_owned
for why). The intended use of this type is to
immediately call into_owned
to convert the value into an
Owned
instead.
Implementations
Converts a Decoded
descriptor into an Owned
descriptor.
Safety
The caller must ensure that the Decoded
descriptor is the only reference to the
descriptor it holds, and that that descriptor is valid. Generally, this is accomplished by
obtaining a Decoded
descriptor by CBOR-decoding the result of a method call, because
OC-Wasm guarantees that any opaque value returned from a method call is represented by a
fresh descriptor.
The reason why this method is unsafe is that a caller could potentially craft an arbitrary
CBOR sequence in a byte buffer, then decode it. If such a decoding operation were to return
an Owned
directly, this would be unsound, as the caller could decode a second
Owned
referring to the same descriptor as an existing Owned
or an
Owned
referring to a closed descriptor. Instead, CBOR decoding (which is itself
safe) can only create a Decoded
, which does not claim exclusive ownership (or even
validity) of the contained descriptor but also cannot actually be used as a descriptor; the
caller is forced to promise those properties in order to convert to the actually useful
Owned
type via this unsafe
method.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Decoded
impl UnwindSafe for Decoded