pub struct Envelope {
pub payload: String,
pub payload_type: String,
pub signatures: Vec<Signature>,
}Expand description
A DSSE envelope. This is the portable artifact unit — everything
Treeship stores, transmits, and verifies is an Envelope.
The payload field is base64url-encoded statement bytes.
The signatures are over PAE(payloadType, decode(payload)).
The outer JSON is never signed — only the PAE construction is.
Fields§
§payload: Stringbase64url-encoded statement bytes (compact JSON).
payload_type: StringMIME type of the statement.
Format: "application/vnd.treeship.<type>.v1+json"
signatures: Vec<Signature>Signatures over PAE(payloadType, decode(payload)).
v1: always exactly one Ed25519 signature.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn payload_bytes(&self) -> Result<Vec<u8>, EnvelopeError>
pub fn payload_bytes(&self) -> Result<Vec<u8>, EnvelopeError>
Decodes the base64url payload back to raw bytes.
Sourcepub fn unmarshal_statement<T: DeserializeOwned>(
&self,
) -> Result<T, EnvelopeError>
pub fn unmarshal_statement<T: DeserializeOwned>( &self, ) -> Result<T, EnvelopeError>
Deserializes the payload into type T.
Sourcepub fn sig_bytes(sig: &Signature) -> Result<Vec<u8>, EnvelopeError>
pub fn sig_bytes(sig: &Signature) -> Result<Vec<u8>, EnvelopeError>
Decodes a single Signature’s sig field to raw bytes.
Sourcepub fn to_json(&self) -> Result<Vec<u8>, EnvelopeError>
pub fn to_json(&self) -> Result<Vec<u8>, EnvelopeError>
Serializes the envelope to compact JSON bytes.
Sourcepub fn from_json(bytes: &[u8]) -> Result<Self, EnvelopeError>
pub fn from_json(bytes: &[u8]) -> Result<Self, EnvelopeError>
Parses an envelope from JSON bytes, validating required fields.