Skip to main content

DeRecEvent

Enum DeRecEvent 

Source
#[non_exhaustive]
pub enum DeRecEvent {
Show 33 variants PairingCompleted { channel_id: ChannelId, pairing_channel_id: ChannelId, kind: SenderKind, peer_communication_info: HashMap<String, String>, }, ReplicaPaired { channel_id: ChannelId, peer_replica_id: u64, }, ShareStored { channel_id: ChannelId, version: u32, replica_id: Option<u64>, }, ReplicaSecretReceived { channel_id: ChannelId, from_replica_id: u64, secret_id: u64, version: u32, secret: Secret, shares: Vec<ChannelShare>, }, ReplicaSecretAcked { channel_id: ChannelId, from_replica_id: u64, secret_id: u64, version: u32, status: i32, memo: String, }, ShareConfirmed { channel_id: ChannelId, version: u32, }, ShareRejected { channel_id: ChannelId, version: u32, status: i32, memo: String, }, SharingComplete { version: u32, confirmed_count: usize, failed_count: usize, threshold_met: bool, }, ShareVerified { channel_id: ChannelId, version: u32, }, SecretsDiscovered { channel_id: ChannelId, secrets: Vec<SecretVersionEntry>, }, RecoveryShareReceived { channel_id: ChannelId, shares_received: usize, }, RecoveryShareError { channel_id: ChannelId, shares_received: usize, error: String, }, SecretRecovered { secret: Secret, }, ActionRequired { channel_id: ChannelId, action: PendingAction, }, AutoAccepted { channel_id: ChannelId, action_kind: PendingActionKind, }, Unpaired { channel_id: ChannelId, }, UnpairRejected { channel_id: ChannelId, status: i32, memo: String, }, PrePairRejected { channel_id: ChannelId, status: i32, memo: String, }, ChannelInfoUpdated { channel_id: ChannelId, }, ChannelInfoUpdateRejected { channel_id: ChannelId, status: i32, memo: String, }, NoOp, PairingStarted { channel_id: ChannelId, kind: SenderKind, }, DiscoveryStarted { channel_id: ChannelId, }, DiscoveryFailed { channel_id: ChannelId, error: String, }, ProtectSecretStarted { channel_id: ChannelId, version: u32, }, ProtectSecretFailed { channel_id: ChannelId, version: u32, error: String, }, VerifySharesStarted { channel_id: ChannelId, version: u32, }, VerifySharesFailed { channel_id: ChannelId, version: u32, error: String, }, RecoverSecretStarted { channel_id: ChannelId, version: u32, }, RecoverSecretFailed { channel_id: ChannelId, version: u32, error: String, }, UnpairStarted { channel_id: ChannelId, }, UpdateChannelInfoStarted { channel_id: ChannelId, }, UpdateChannelInfoFailed { channel_id: ChannelId, error: String, },
}
Expand description

Events emitted by super::DeRecProtocol::process.

The application reacts to these instead of routing raw messages manually.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PairingCompleted

Pairing completed — the shared key for channel_id is now persisted.

kind is the local party’s role in the pairing, also persisted as crate::protocol::types::Channel::role and consulted by the orchestrator on every subsequent flow start and inbound message. Applications use it to decide what to do next:

Fields

§channel_id: ChannelId

Long-term channel_id both peers atomically rotated to at the end of the handshake. All post-pairing traffic and library state for this relationship keys on this value.

§pairing_channel_id: ChannelId

The transient channel_id used only during the pairing handshake — the one that traveled on the ContactMessage and the pairing envelopes. Already replaced with channel_id in library state; the library will refuse messages routed to it from this point on. Provided so applications that persisted the pairing id (e.g. displayed it in a UI or mirrored it to their own store) can rekey their own records.

§peer_communication_info: HashMap<String, String>

Key-value pairs extracted from the peer’s CommunicationInfo (e.g. "name", "email", "phone"). Empty if the peer sent none.

§

ReplicaPaired

A replica-mode pair handshake completed. Fires alongside Self::PairingCompleted on replica channels.

Under the unidirectional replica model, the local side’s role (ReplicaSource or ReplicaDestination) is already on crate::protocol::types::Channel::role — this event just adds the peer’s replica_id, which the app needs as a from_replica_id when subsequent secret syncs arrive or when targeting the peer via ProtectSecret.

Fields

§channel_id: ChannelId

The channel the pair handshake just completed on.

§peer_replica_id: u64

The peer’s replica identity, extracted from derec.replica_id in the peer’s CommunicationInfo.

§

ShareStored

A share was accepted and stored locally (Helper side).

replica_id is the stable per-device identifier of the writer, copied from the inbound StoreShareRequestMessage.replica_id. None indicates the writer was a non-replica Owner. The field is metadata for the application; see crate::protocol::DeRecShareStore::save for the storage disambiguation contract that makes concurrent writes from distinct replicas coexist.

Fields

§channel_id: ChannelId
§version: u32
§replica_id: Option<u64>
§

ReplicaSecretReceived

A ReplicaSource peer pushed a secret sync on a ReplicaDestination channel. The library has already auto-acked the inbound StoreShareRequest and decoded the ReplicaSecretPayload into typed fields — the application can install secret directly, optionally using shares to verify or to take over the recovery flow toward each helper.

Recovery transitivity: secret.helpers[i].shared_key lets the receiver authenticate as the Source toward each helper. For replica-to-replica traffic, all replicas share a single group-wide channel key (see crate::protocol::types::ReplicaSecretPayload for the handover protocol) — the receiver’s own crate::protocol::DeRecSecretStore entry for this channel holds that group key, so impersonating the Source toward another destination is just a normal channel-key load. Treat the receiving device accordingly — see crate::protocol::types::ReplicaInfo for the security note.

Fields

§channel_id: ChannelId

The channel the request arrived on.

§from_replica_id: u64

The peer’s replica identity (from Channel.replica_id, populated at pair time).

§secret_id: u64

secret_id echoed from the inbound StoreShareRequest.

§version: u32

version echoed from the inbound StoreShareRequest.

§secret: Secret

Decoded full secret — same shape the sender wrote. The helpers, replicas, secrets, and owner_replica_id fields carry the canonical roster snapshot for this version.

§shares: Vec<ChannelShare>

Per-helper VSS share map. Each entry pairs a helper’s channel_id with the serialized CommittedDeRecShare bytes the helper received — sufficient material for the receiver to drive a recovery against those helpers if needed.

§

ReplicaSecretAcked

A replica peer’s StoreShareResponse to a secret sync we sent earlier. Fires on the replica channel, mirroring Self::ShareConfirmed / Self::ShareRejected on the helper side.

status and memo come straight from the peer’s StoreShareResponseMessage.result. Apps decide whether to retry, rebroadcast, or surface the failure to the user.

Fields

§channel_id: ChannelId
§from_replica_id: u64

The peer’s replica identity (from Channel.replica_id).

§secret_id: u64

secret_id echoed from the response.

§version: u32

version echoed from the response.

§status: i32

The StatusEnum value from the peer’s response.

§memo: String

Human-readable explanation from the peer (empty on Ok).

§

ShareConfirmed

A Helper confirmed it stored our share (Owner side).

Fields

§channel_id: ChannelId
§version: u32
§

ShareRejected

A Helper rejected or failed to store our share (Owner side).

The protocol absorbs sharing failures and converts them to events so the application can display per-participant progress. status and memo come from the Helper’s response (or are synthetic for timeouts).

Fields

§channel_id: ChannelId
§version: u32
§status: i32

The StatusEnum value from the Helper’s response.

§memo: String

Human-readable reason from the Helper, or "timeout".

§

SharingComplete

A sharing round has completed (all participants responded or timed out).

Emitted once per DeRecFlow::ProtectSecret flow after every targeted Helper has either confirmed, rejected, or timed out.

Fields

§version: u32
§confirmed_count: usize
§failed_count: usize
§threshold_met: bool

true when confirmed_count >= threshold.

§

ShareVerified

A Helper’s verification proof checked out (Owner side).

Fields

§channel_id: ChannelId
§version: u32
§

SecretsDiscovered

A Helper reported all secrets it currently stores for this channel (Owner side).

Emitted after the Owner calls super::DeRecProtocol::start with DeRecFlow::Discovery and the Helper responds. Each SecretVersionEntry carries a secret_id and a list of (version, description) pairs for every share the Helper holds.

The application should persist this list and, once enough Helpers have responded, call super::DeRecProtocol::start with DeRecFlow::RecoverSecret for the desired (secret_id, version).

Fields

§channel_id: ChannelId
§secrets: Vec<SecretVersionEntry>

All secrets and their stored versions the Helper holds for this channel.

§

RecoveryShareReceived

A recovery share response was received from a Helper but reconstruction cannot succeed yet — more shares are needed to meet the threshold.

  • channel_id identifies the Helper that sent this share response.
  • shares_received is the total number of share responses collected so far for this (secret_id, version) recovery context.

Fields

§channel_id: ChannelId
§shares_received: usize
§

RecoveryShareError

A recovery share response was received but reconstruction failed for a reason other than insufficient shares (e.g. corrupted share, version mismatch, decode error).

  • channel_id identifies the Helper that sent this share response.
  • shares_received is the total number of share responses collected so far.
  • error describes the failure cause.

Fields

§channel_id: ChannelId
§shares_received: usize
§error: String
§

SecretRecovered

Recovery completed — the reconstructed crate::protocol::types::Secret is returned exactly once.

The variant mirrors Self::ReplicaSecretReceived: the inner secret carries the full typed snapshot — secrets: Vec<UserSecret> (the user-facing entries the owner originally protected) plus the roster snapshot (helpers, replicas, owner_replica_id) captured at distribution time. Apps that only care about the user-facing entries read secret.secrets; the roster fields are useful when the recovering owner wants to know who held the shares, re-pair with the same helpers, or sync replicas after the recovery completes.

The library decodes the two-layer (DeRecSecretSecret) protobuf wrapping internally; a decode failure surfaces as Self::RecoveryShareError for that final share, not as SecretRecovered with bogus contents.

Pass secret to super::DeRecProtocol::restore on a fresh protocol instance to commit canonical helper / replica state and wipe the throwaway recovery-mode channels.

Fields

§secret: Secret
§

ActionRequired

An incoming request requires application confirmation before the library responds.

Emitted by super::DeRecProtocol::process for every incoming request that is not opted into auto-accept by AutoAcceptPolicy. The application must call super::DeRecProtocol::accept or super::DeRecProtocol::reject to complete the flow.

Fields

§channel_id: ChannelId
§

AutoAccepted

The library auto-accepted an incoming request because the configured AutoAcceptPolicy opted in to its flow.

Emitted by super::DeRecProtocol::process in place of Self::ActionRequired for the auto-accepted flow, followed (in the same event vec) by the same flow events a manual accept(action) would have produced (e.g. ShareStored, PairingCompleted, Unpaired). Applications use this event for observability / audit logging — no further action is required from the caller.

Fields

§channel_id: ChannelId
§action_kind: PendingActionKind

The action’s discriminant. The original PendingAction payload is consumed by the internal accept and is not surfaced here; routing on the kind is enough for observability since the flow-completion events that follow carry the per-flow details.

§

Unpaired

The local channel state for channel_id has been dropped as the result of an unpair flow.

Surfaces on both sides of the flow:

  • Initiator: emitted when (a) UnpairAck::NotRequired and the request has just been sent, (b) UnpairAck::Required and the peer acknowledged with Ok, or (c) UnpairAck::Required and the configured timeout elapsed without a response.
  • Responder: emitted by super::DeRecProtocol::accept after the channel/share/secret state for the requesting peer has been removed.

Fields

§channel_id: ChannelId
§

UnpairRejected

The peer answered an outbound unpair request with a non-Ok status.

The initiator’s local state is not dropped — the application decides what to do (retry, escalate, or force-delete locally).

Fields

§channel_id: ChannelId
§status: i32

The StatusEnum value from the peer’s response.

§memo: String

Human-readable reason from the peer.

§

PrePairRejected

The contact creator answered our PrePairRequest with a non-Ok status (scanner side, HashedKeys flow).

The scanner cannot proceed to a normal PairRequest because the public keys were never published. Distinct from crate::primitives::pairing::PairingError::PrePairHashMismatch, which fires when keys were published but failed the binding-hash check — a cryptographic failure surfaced as Err, not an event.

Fields

§channel_id: ChannelId
§status: i32

The StatusEnum value from the contact creator’s response.

§memo: String

Human-readable reason from the contact creator.

§

ChannelInfoUpdated

The stored crate::protocol::types::Channel for channel_id has been updated with new communication info and/or transport endpoint.

Surfaces on both sides of the flow:

The new communication_info / transport_protocol values are already on the local crate::protocol::types::Channel by the time the event fires; applications that care about the post-update state read it from the channel store directly.

Fields

§channel_id: ChannelId
§

ChannelInfoUpdateRejected

The peer answered an outbound UpdateChannelInfo request with a non-Ok status. The peer’s stored state is unchanged. The initiator’s own state is also unaffected.

Fields

§channel_id: ChannelId
§status: i32

The StatusEnum value from the peer’s response.

§memo: String

Human-readable reason from the peer.

§

NoOp

Well-formed message with no actionable effect (e.g. an ACK).

§

PairingStarted

A pairing flow was initiated for channel_id with the local role kind. Emitted synchronously from super::DeRecProtocol::start when the PairRequest (or PrePairRequest for HashedKeys / NoKeys modes) was dispatched successfully. Followed by Self::PairingCompleted (or a failure variant) once the peer responds. On a local send failure, start returns Err instead — no PairingStarted is emitted.

Fields

§channel_id: ChannelId
§kind: SenderKind

The local party’s role in the pairing (same value that will appear on Self::PairingCompleted::kind and be persisted as crate::protocol::types::Channel::role).

§

DiscoveryStarted

A discovery request was dispatched to channel_id. Emitted per targeted channel by super::DeRecProtocol::start. Followed by Self::SecretsDiscovered once the helper responds.

Fields

§channel_id: ChannelId
§

DiscoveryFailed

A discovery request could not be dispatched to channel_id. Emitted per targeted channel by super::DeRecProtocol::start when the outbound send (or per-channel preparation) failed. The remaining channels in the same fan-out are unaffected.

Fields

§channel_id: ChannelId
§error: String
§

ProtectSecretStarted

A share-storage request was dispatched to channel_id for version. Emitted per targeted helper (and per targeted replica destination) by super::DeRecProtocol::start. Followed by Self::ShareStored / Self::ShareConfirmed / Self::ShareRejected as the peer responds; the whole round finishes with Self::SharingComplete.

Fields

§channel_id: ChannelId
§version: u32
§

ProtectSecretFailed

A share-storage request could not be dispatched to channel_id for version. Remaining fan-out targets are unaffected.

Fields

§channel_id: ChannelId
§version: u32
§error: String
§

VerifySharesStarted

A verify-share challenge was dispatched to channel_id for version. Followed by Self::ShareVerified once the helper responds.

Fields

§channel_id: ChannelId
§version: u32
§

VerifySharesFailed

A verify-share challenge could not be dispatched to channel_id for version.

Fields

§channel_id: ChannelId
§version: u32
§error: String
§

RecoverSecretStarted

A recovery share request was dispatched to channel_id for version. Followed by Self::RecoveryShareReceived / Self::RecoveryShareError / Self::SecretRecovered as helper responses arrive.

Fields

§channel_id: ChannelId
§version: u32
§

RecoverSecretFailed

A recovery share request could not be dispatched to channel_id for version.

Fields

§channel_id: ChannelId
§version: u32
§error: String
§

UnpairStarted

An unpair request was dispatched to channel_id. Followed by Self::Unpaired once the peer acknowledges (or, under UnpairAck::NotRequired, emitted in the same event vec immediately after UnpairStarted).

Fields

§channel_id: ChannelId
§

UpdateChannelInfoStarted

An update-channel-info request was dispatched to channel_id. Followed by Self::ChannelInfoUpdated once the peer responds.

Fields

§channel_id: ChannelId
§

UpdateChannelInfoFailed

An update-channel-info request could not be dispatched to channel_id.

Fields

§channel_id: ChannelId
§error: String

Trait Implementations§

Source§

impl Debug for DeRecEvent

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V