Skip to main content

EncryptedLinkHandshake

Struct EncryptedLinkHandshake 

Source
pub struct EncryptedLinkHandshake { /* private fields */ }
Expand description

Handle to an in-progress Noise handshake.

Created by initiate_encrypted_link (initiator) or accept_encrypted_link (responder). Drive the handshake forward by repeatedly calling advance_handshake until it returns HandshakeProgress::Complete.

The caller owns polling, timeouts, and backoff. Homeserver write failures are automatically recovered up to DEFAULT_MAX_RECOVERY_ATTEMPTS unless overridden.

Implementations§

Source§

impl EncryptedLinkHandshake

Source

pub async fn prepare_next_step( self, ) -> Result<Option<PreparedEncryptedLinkHandshakeStep>>

Fetch at most one bounded packet and prepare one existing Noise step. Returns None only for an absent required packet (404/410). No publication occurs. The caller must validate the source checkpoint before applying either the result or an error, and persist pending output before sending. Session authorization, capability scope, and rotation are caller-owned.

Source

pub fn finish_if_complete(self) -> Result<HandshakeProgress>

Complete a restored handshake without any reads or writes. An incomplete handshake is returned unchanged. Restore only an acknowledged checkpoint; authorization and key rotation are caller-owned.

Source

pub fn remote_static_public_key(&self) -> Option<&[u8]>

X25519 static key authenticated by the completed Noise handshake. Returns None while the handshake is incomplete. The caller must authenticate this key before trusting the completed link.

Source

pub fn set_max_recovery_attempts(&mut self, max: u32) -> &mut Self

Set the maximum number of consecutive automatic recovery attempts before advance_handshake gives up and returns an error whose underlying cause is PaykitError::Transport.

Default: DEFAULT_MAX_RECOVERY_ATTEMPTS (3).

Source

pub fn snapshot(&self) -> Result<EncryptedLinkHandshakeSnapshot>

Capture the current handshake state as a serializable snapshot.

Snapshot bytes include sensitive key material and must be stored as secrets.

Source

pub fn serialize(&self) -> Result<Vec<u8>>

Serialize the current handshake state to bytes for persistence.

Convenience method equivalent to self.snapshot()?.serialize().

Source

pub fn config(&self) -> &Arc<PubkyNoiseConfig> ⓘ

Access the shared Noise configuration for this handshake.

Useful for passing to restore_encrypted_link_handshake_from_config when performing in-process recovery without an app restart.

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

Source§

fn compat(self) -> Compat<T> ⓘ
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T> ⓘ

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T> ⓘ

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more