GattSyncProtocol

Struct GattSyncProtocol 

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

GATT Sync Protocol coordinator

Ties together batching, delta encoding, and chunked transfer for efficient CRDT sync over BLE.

Implementations§

Source§

impl GattSyncProtocol

Source

pub fn new(node_id: NodeId, config: SyncConfig) -> Self

Create a new sync protocol instance

Source

pub fn with_defaults(node_id: NodeId) -> Self

Create with default config

Source

pub fn set_time(&mut self, time_ms: u64)

Set the current time

Source

pub fn set_mtu(&mut self, mtu: usize)

Set the MTU (after negotiation)

Source

pub fn state(&self) -> SyncState

Get current state

Source

pub fn vector_clock(&self) -> &VectorClock

Get the vector clock

Source

pub fn add_peer(&mut self, peer_id: &NodeId)

Add a peer for sync

Source

pub fn remove_peer(&mut self, peer_id: &NodeId)

Remove a peer

Source

pub fn queue_operation(&mut self, op: CrdtOperation) -> bool

Queue a CRDT operation for sync

Source

pub fn should_sync(&self) -> bool

Check if we should sync now

Source

pub fn prepare_sync(&mut self, peer_id: &NodeId) -> Vec<SyncChunk>

Prepare a sync to a peer

Returns the chunks to send

Source

pub fn next_tx_chunk(&mut self) -> Option<SyncChunk>

Get next chunk to send (if any)

Source

pub fn queue_chunks(&mut self, chunks: Vec<SyncChunk>)

Queue chunks for sending

Source

pub fn has_pending_tx(&self) -> bool

Check if there are chunks to send

Source

pub fn process_received( &mut self, chunk: SyncChunk, peer_id: &NodeId, ) -> Option<Vec<CrdtOperation>>

Process a received chunk

Returns decoded operations if message is complete

Source

pub fn ack_send(&mut self)

Acknowledge completion of send

Source

pub fn reset(&mut self)

Reset protocol state (e.g., on reconnection)

Source

pub fn reset_peer(&mut self, peer_id: &NodeId)

Reset sync state for a specific peer

Source

pub fn tick(&mut self)

Run periodic maintenance

Source

pub fn stats(&self) -> SyncStats

Get sync statistics

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> 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, 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.