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

Formats the value using the given formatter. Read more

Decode a value using the given Decoder.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.