EnvelopeCase

Enum EnvelopeCase 

Source
pub enum EnvelopeCase {
    Node {
        subject: Envelope,
        assertions: Vec<Envelope>,
        digest: Digest,
    },
    Leaf {
        cbor: CBOR,
        digest: Digest,
    },
    Wrapped {
        envelope: Envelope,
        digest: Digest,
    },
    Assertion(Assertion),
    Elided(Digest),
    KnownValue {
        value: KnownValue,
        digest: Digest,
    },
    Encrypted(EncryptedMessage),
    Compressed(Compressed),
}
Expand description

The core structural variants of a Gordian Envelope.

Each variant of this enum represents a different structural form that an envelope can take, as defined in the Gordian Envelope IETF Internet Draft. The different cases provide different capabilities and serve different purposes in the envelope ecosystem.

The EnvelopeCase is the internal representation of an envelope’s structure. While each case has unique properties, they all maintain a digest that ensures the integrity of the envelope.

It is advised to use the other Envelop APIs for most uses. Please see the queries module for more information on how to interact with envelopes.

Variants§

§

Node

Represents an envelope with a subject and one or more assertions.

A node is the fundamental structural component for building complex data structures with Gordian Envelope. It consists of a subject and a set of assertions about that subject.

The digest of a node is derived from the digests of its subject and all assertions, ensuring that any change to the node or its components would result in a different digest.

Fields

§subject: Envelope

The subject of the node

§assertions: Vec<Envelope>

The assertions attached to the subject

§digest: Digest

The digest of the node

§

Leaf

Represents an envelope containing a primitive CBOR value.

A leaf is the simplest form of envelope, containing a single CBOR value such as a string, number, or boolean. Leaves are the terminal nodes in the envelope structure.

The digest of a leaf is derived directly from its CBOR representation.

Fields

§cbor: CBOR

The CBOR value contained in the leaf

§digest: Digest

The digest of the leaf

§

Wrapped

Represents an envelope that wraps another envelope.

Wrapping provides a way to encapsulate an entire envelope as the subject of another envelope, enabling hierarchical structures and metadata attachment.

The digest of a wrapped envelope is derived from the digest of the envelope it wraps.

Fields

§envelope: Envelope

The envelope being wrapped

§digest: Digest

The digest of the wrapped envelope

§

Assertion(Assertion)

Represents a predicate-object assertion.

An assertion is a statement about a subject, consisting of a predicate (what is being asserted) and an object (the value of the assertion). Assertions are attached to envelope subjects to form semantic statements.

For example, in the statement “Alice hasEmail alice@example.com”:

  • The subject is “Alice”
  • The predicate is “hasEmail”
  • The object is “alice@example.com”
§

Elided(Digest)

Represents an envelope that has been elided, leaving only its digest.

Elision is a key privacy feature of Gordian Envelope, allowing parts of an envelope to be removed while maintaining the integrity of the digest tree. This enables selective disclosure of information.

§

KnownValue

Represents a value from a namespace of unsigned integers used for ontological concepts.

Known Values are 64-bit unsigned integers used to represent stand-alone ontological concepts like relationships (isA, containedIn), classes (Seed, PrivateKey), or enumerated values (MainNet, OK). They provide a compact, deterministic alternative to URIs for representing common predicates and values.

Using Known Values instead of strings for common predicates offers several advantages:

  • More compact representation (integers vs. long strings/URIs)
  • Standardized semantics across implementations
  • Deterministic encoding for cryptographic operations
  • Resistance to manipulation attacks that target string representations

Known Values are displayed with single quotes, e.g., 'isA' or by their numeric value like '1' (when no name is assigned).

This variant is only available when the known_value feature is enabled.

Fields

§value: KnownValue

The Known Value instance containing the integer value and optional name

§digest: Digest

The digest of the known value

§

Encrypted(EncryptedMessage)

Represents an envelope that has been encrypted.

Encryption is a privacy feature that allows parts of an envelope to be encrypted while maintaining the integrity of the digest tree. The encrypted content can only be accessed by those with the appropriate key.

This variant is only available when the encrypt feature is enabled.

§

Compressed(Compressed)

Represents an envelope that has been compressed.

Compression reduces the size of an envelope while maintaining its full content and digest integrity. Unlike elision or encryption, compression doesn’t restrict access to the content, but simply makes it more compact.

This variant is only available when the compress feature is enabled.

Trait Implementations§

Source§

impl Debug for EnvelopeCase

Source§

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

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

impl From<EnvelopeCase> for Envelope

Conversion from EnvelopeCase to Envelope.

This allows creating an envelope directly from an envelope case variant.

Source§

fn from(case: EnvelopeCase) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for EnvelopeCase

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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 Eq for EnvelopeCase

Source§

impl StructuralPartialEq for EnvelopeCase

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V