Skip to main content

CatchupSnapshot

Struct CatchupSnapshot 

Source
pub struct CatchupSnapshot {
    pub v: u8,
    pub conversation_metas: Vec<CatchupConversationEntry>,
    pub last_app_events_per_conv: Vec<CatchupAppEventEntry>,
}
Expand description

[CR-13] Catchup snapshot delivered to a newly-linked device.

Populates the catchup_snapshot field of LinkingTicket so the new device boots with a populated conversation list + last-known plaintext per conversation, instead of an empty UI until peers re-Welcome.

group_state_bytes is reserved for the [CR-7] DeviceGroup-snapshot machinery; until CR-7 lands it’s always empty (Vec::new()) on every meta. The encoding is forward- compatible: a snapshot produced today will decode cleanly on a future SDK build that understands CR-7, and a future-produced snapshot decodes on today’s SDK (we just ignore the populated group_state_bytes).

last_app_events_per_conv is host-supplied — the SDK doesn’t store decrypted plaintext on its own, so the host passes through whatever it wants the new device to see on launch (typically: the last N AppEvent bytes per conversation).

Fields§

§v: u8

Format version. 1 today; bumped on incompatible CBOR-shape changes.

§conversation_metas: Vec<CatchupConversationEntry>

Conversation list + per-conversation MLS state. group_state_bytes is empty pre-CR-7; the field is reserved so the wire format doesn’t churn when CR-7 ships.

§last_app_events_per_conv: Vec<CatchupAppEventEntry>

Last-known decrypted AppEvent bytes per conversation. Host-supplied; opaque to the SDK. Each entry is keyed by ConversationId.

Implementations§

Source§

impl CatchupSnapshot

Source

pub fn empty() -> Self

Build an empty snapshot (no metas, no events). Equivalent to “no catchup data.”

Source

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

CBOR-encode for inclusion in a LinkingTicket::catchup_snapshot.

Returns Err(Error::Invalid) if the encoded size exceeds CATCHUP_SNAPSHOT_HARD_CAP (256 KB). Sizes between the soft cap (64 KB) and the hard cap log a warning but still succeed — they’re suboptimal but not refused.

Source

pub fn encode_within_cap(self) -> Result<Vec<u8>>

CBOR-encode, guaranteeing the result fits under CATCHUP_SNAPSHOT_HARD_CAP by shedding payload until it does — instead of erroring like [encode].

[encode] is the strict encoder used by conformance vectors and callers that build their own bounded snapshots. build_linking_ticket, by contrast, snapshots every conversation the user is in, so a user with many (or large) groups can blow the 256 KB ticket cap through no fault of the host — and a hard error there breaks device linking entirely (the new device can’t even join the DeviceGroup). This method makes linking degrade gracefully instead of failing:

  1. Fast path — if the full snapshot already fits, return it.
  2. Drop group_state_bytes (CR-7 per-group MLS state), largest first, until it fits. An empty group_state_bytes is an explicitly-supported receiver case (§CR-7): that conversation is caught up via the normal re-Welcome path instead of local import. Ping’s hosts (web + iOS) already re-admit every chat after linking, so dropping this state costs nothing functionally — only the “boot already able to decrypt” optimisation for the shed conversations.
  3. If still over (pathological host-supplied last_app_events), trim last_app_events_per_conv from the tail.
  4. If still over (thousands of conversation_metas), drop metas from the tail. The new device then relies fully on normal sync — identical to the pre-CR-13 empty-snapshot behaviour.

Conversation metadata is preserved as long as it fits, so the common large-account case still boots with a populated conversation list. Whatever is shed is logged.

Source

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

Decode a CBOR-encoded snapshot. Refuses sizes over CATCHUP_SNAPSHOT_HARD_CAP to bound attacker-controlled allocation; refuses unknown v to avoid silently dropping fields a future version added.

Trait Implementations§

Source§

impl Clone for CatchupSnapshot

Source§

fn clone(&self) -> CatchupSnapshot

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 CatchupSnapshot

Source§

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

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

impl<'de> Deserialize<'de> for CatchupSnapshot

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 CatchupSnapshot

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

Source§

type Classified = T

Source§

fn classify(self) -> T

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

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

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

Source§

fn vzip(self) -> V

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