Skip to main content

Envelope

Struct Envelope 

Source
pub struct Envelope {
Show 14 fields pub acl: u8, pub msg_id: String, pub in_reply_to: Option<String>, pub from: Aid, pub to: Aid, pub ts: i64, pub ttl: u32, pub reply_with: Option<String>, pub hop_count: u8, pub performative: Performative, pub body: Body, pub sig: Option<Vec<u8>>, pub rational_effect: Option<String>, pub feasibility_precondition: Option<String>,
}
Expand description

The ACL envelope (spec §4). Field order is wire order.

Fields§

§acl: u8§msg_id: String

128-bit id, hex-encoded (32 chars).

§in_reply_to: Option<String>§from: Aid§to: Aid§ts: i64

unix milliseconds UTC

§ttl: u32§reply_with: Option<String>§hop_count: u8§performative: Performative§body: Body§sig: Option<Vec<u8>>

Ed25519 signature over the encoded envelope with sig absent.

§rational_effect: Option<String>

§30: what the sender EXPECTS to happen in the world if the message is honoured (rational effect). Machine-checkable against the sender’s declared semantics.

§feasibility_precondition: Option<String>

§30: what must have been true of the sender for this message to be sincere (feasibility precondition).

Implementations§

Source§

impl Envelope

Source

pub fn new(from: Aid, to: Aid, performative: Performative, body: Body) -> Self

Source

pub fn with_intent(self, fp: &str, re: &str) -> Self

§30: declare the intent pair (FP/RE) on this envelope.

Source

pub fn encode_unsigned(&self) -> Result<Vec<u8>, AclError>

Serialize the unsigned envelope (what the signature covers).

Source

pub fn encode(&self) -> Result<Vec<u8>, AclError>

Full wire encoding.

Source

pub fn decode(bytes: &[u8]) -> Result<Self, AclError>

Source

pub fn sign(&mut self, key: &SigningKey) -> Result<(), AclError>

Sign with an Ed25519 key. sig covers the envelope without sig.

Source

pub fn verify(&self, vk: &VerifyingKey) -> Result<bool, AclError>

Verify the signature against a public key.

Source

pub fn is_expired(&self, now_ms: i64) -> bool

Trait Implementations§

Source§

impl Clone for Envelope

Source§

fn clone(&self) -> Envelope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Envelope

Source§

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

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

impl<'de> Deserialize<'de> for Envelope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Envelope

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.