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
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.
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
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: KnownValueThe Known Value instance containing the integer value and optional name
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
impl Debug for EnvelopeCase
Source§impl From<EnvelopeCase> for Envelope
Conversion from EnvelopeCase to Envelope.
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
fn from(case: EnvelopeCase) -> Self
Source§impl PartialEq for EnvelopeCase
impl PartialEq for EnvelopeCase
impl Eq for EnvelopeCase
impl StructuralPartialEq for EnvelopeCase
Auto Trait Implementations§
impl Freeze for EnvelopeCase
impl RefUnwindSafe for EnvelopeCase
impl !Send for EnvelopeCase
impl !Sync for EnvelopeCase
impl Unpin for EnvelopeCase
impl UnwindSafe for EnvelopeCase
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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