Struct didcomm_rs::Message[][src]

pub struct Message {
    pub jwm_header: JwmHeader,
    // some fields omitted
}
Expand description

DIDComm message structure. Specification

Fields

jwm_header: JwmHeader

JOSE header, which is sent as public part with JWE.

Implementations

Generates EMPTY default message. Use extension messages to build final one before sending.

Setter of from header Helper method.

Setter of to header Helper method.

Setter of m_type @type header Helper method.

Getter of the body as ref of bytes slice. Helpe method.

Setter of the body Helper method.

Sets times of creation as now and, optional, expires time.

Parameters

  • expires - time in seconds since Unix Epoch when message is considered to be invalid.

Checks if message is rotation one. Exposed for explicit checks on calling code level.

If message is_rotation() true - returns from_prion claims. Errors otherwise with Error::NoRotationData

&DidcommHeader getter.

Setter of didcomm_header. Replaces existing one with provided by consuming both values. Returns modified instance of Self.

Adds (or updates) custom unique header key-value pair to the header. This portion of header is not sent as JOSE header.

Creates set of Jwm related headers for the JWE Modifies JWM related header portion to match encryption implementation and leaves other parts unchanged. TODO + FIXME: complete implementation

Creates set of Jwm related headers for the JWS Modifies JWM related header portion to match signature implementation and leaves Other parts unchanged.

For resolve feature will set kid header automatically based on the did document resolved.

Serializez current state of the message into json. Consumes original message - use as raw sealing of envelope.

Seals self and returns ready to send JWE

Parameters

ek - encryption key for inner message payload JWE encryption

Signs raw message and then packs it to encrypted envelope Spec

Parameters

ek - encryption key for inner message payload JWE encryption

sk - signing key for enveloped message JWS encryption

Wrap self to be mediated by some mediator. Warning: Should be called on a Message instance which is ready to be sent! If message is not properly set up for crypto - this method will propogate error from called .seal() method. Takes one mediator at a time to make sure that mediated chain preserves unchanged. This method can be chained any number of times to match all the mediators in the chain.

Parameters

ek - encryption key for inner message payload JWE encryption

to - list of destination recepients. can be empty (Optional) String::default()

form - used same as in wrapped message, fails if not present with DidResolveFailed error.

TODO: Add examples

Associated functions implementations. Possibly not required as Jwe serialization covers this.

Parses iv value as Vec<u8> from public header. Both regular JSON and Compact representations are accepted. Returns Error on failure. TODO: Add examples

Construct a message from received data. Raw or JWE payload is accepted.

Encrypts current message by consuming it. Uses provided cryptography function to perform the encryption. Agnostic of actual algorythm used. Consuming is to make sure no changes are possible post packaging / sending. Returns (JwmHeader, Vec<u8>) to be sent to receiver.

Decrypts received cypher into instance of Message. Received message should be encrypted with our pub key. Returns Ok(Message) if decryption / deserialization succeded. Error othervice.

Signs message and turns it into Jws envelope. Err is returned if message is not properly prepared or data is malformed. Jws enveloped payload is base64_url encoded

Verifyes signature and returns payload message on verification success. Err return if signature invalid or data is malformed. Expects Jws’s payload to be a valid serialized Message and base64_url encoded.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

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

This method tests for !=.

Serialize this value into the given Serde serializer. 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

Converts self into T using Into<T>. Read more

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. Read more

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.