MobileMeshSession

Struct MobileMeshSession 

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

Long-lived Rust protocol engine used by the mobile app.

ping is the only ping operation exposed to Swift. The existing Rust node layer owns its nonce, authenticated echo request, counter reservation, response matching, and timeout.

Implementations§

Source§

impl MobileMeshSession

Source

pub async fn new( identity: Arc<MobileIdentity>, counter_store: Arc<MobileCounterStore>, ) -> Result<Arc<Self>, MobileMeshError>

Source

pub fn ping( &self, peer_address: String, timeout_ms: u64, ) -> Result<u64, MobileMeshError>

Source

pub async fn advertise_identity( &self, name: Option<String>, timestamp: Option<u32>, ) -> Result<(), MobileMeshError>

Broadcast a signed node-identity advertisement describing this phone.

The bundle always carries the standalone EdDSA signature because a broadcast frame has no MIC to authenticate it.

Source

pub async fn advertise_identity_scheduled( &self, name: Option<String>, timestamp: Option<u32>, ) -> Result<(), MobileMeshError>

The same advertisement, sent because the phone’s own interval came round rather than because someone asked for it.

Reaches only direct neighbours. A repeated statement of who this phone is does not need to cross the mesh every time; introducing it, which is what the manual send does, is the case that does.

Source

pub async fn send_beacon(&self) -> Result<(), MobileMeshError>

Broadcast an empty beacon: no payload, so what it publishes is the path back to this phone rather than who this phone is. Costs a fraction of an advertisement.

Source

pub async fn request_identity( &self, peer_address: String, ) -> Result<(), MobileMeshError>

Solicit a specific peer’s current node identity by sending a targeted MAC Identity Request (command 1). This resolves once the request has been handed to the transport; the peer’s identity response arrives later as a NodeIdentity advertisement on the normal receive path (surfaced through poll_update’s advertisement events).

Source

pub async fn discover_identities( &self, role_code: Option<u8>, capability_bits: Option<u8>, ) -> Result<(), MobileMeshError>

Solicit identities from nearby nodes with one zero-hop broadcast MAC Identity Request.

The request goes out as a direct broadcast with no flood budget, so repeaters never carry it — the blast radius is exactly the nodes in radio range. It carries this phone’s full source address, so a matching node can reply with a targeted unicast without any prior contact; replies arrive as ordinary NodeIdentity advertisements on the receive path. role_code and capability_bits narrow which nodes respond (AND-combined when both are given); None for both asks every node in range.

Source

pub async fn request_identity_by_hint( &self, conversation_address: String, hint: Vec<u8>, ) -> Result<(), MobileMeshError>

Ask a channel member who is known only by their claimed hint to send their identity.

A group message carries a 3-byte hint and nothing else, so there is no address to unicast a request to. This goes out over the channel itself, filtered to that hint, and only the member it names answers — with a targeted unicast, since the request carries this phone’s full address.

The request is routed by what that member’s own frames have shown: their observed trace route if one is known, otherwise a flood budget bounded by the hops their last message took rather than a default.

Source

pub async fn set_chat_display_name( &self, name: String, ) -> Result<(), MobileMeshError>

Set whether this phone answers Identity Requests with its own identity — the passive counterpart of [discover_identities]: discoverable phones show up in other people’s Discover sessions.

name is the display name carried in replies (truncated to the 24-byte wire limit). The session starts discoverable with no name; the app pushes the stored preference and name right after install and again whenever either changes. Replies are targeted authenticated unicasts, never broadcasts. Set the name carried on this phone’s own group messages.

A multicast reaches members holding no identity for us, so a group message says who sent it or arrives anonymous. Direct messages never carry it: the recipient authenticated us by key. Empty clears it.

Source

pub async fn set_discoverable( &self, enabled: bool, name: Option<String>, ) -> Result<(), MobileMeshError>

Source

pub async fn set_advertised_location( &self, location: Option<MobileMeshSharedLocationRecord>, ) -> Result<(), MobileMeshError>

Set the position this phone’s identity carries, or None to stop sharing one.

Reaches every live identity payload — advertisements, manual and scheduled, and Identity Request replies while discoverable — but never the shareable QR/URI bundle: that bundle is durable, and a position frozen into it would go stale and then travel wherever the QR is pasted. The coordinate is reduced to the cell named by precision_bytes before it is stored, so nothing finer ever sits in this session, whatever later reads it.

Source

pub async fn peer_route( &self, peer_address: String, ) -> Result<MobileMeshRouteRecord, MobileMeshError>

Report the route the MAC will use for the next frame sent to peer.

Read-only: an unregistered peer reads as Unknown rather than being registered as a side effect of being inspected.

Source

pub async fn clear_peer_route( &self, peer_address: String, ) -> Result<bool, MobileMeshError>

Forget the route cached for peer, returning whether one was held.

The peer, its keys, and its counters are untouched; only the learned path is discarded, so the next send starts over from flood delivery.

Source

pub async fn sign_identity_bundle( &self, name: Option<String>, timestamp: Option<u32>, ) -> Result<Vec<u8>, MobileMeshError>

Build and sign this phone’s node-identity bundle without transmitting it, for embedding in the shareable umsh:n: URI and QR code.

Source

pub async fn register_peers( &self, peer_addresses: Vec<String>, ) -> Result<(), MobileMeshError>

Source

pub async fn remove_peers( &self, peer_addresses: Vec<String>, ) -> Result<(), MobileMeshError>

Remove peers from the live MAC. Idempotent: a peer that was never registered is already in the requested state, so it is not an error. A removed peer that transmits again may be auto-re-registered (unpinned) by the MAC — removal here tracks the app’s stored peer list, it is not a block list.

Source

pub async fn register_channels( &self, keys: Vec<Vec<u8>>, ) -> Result<(), MobileMeshError>

Register channel keys with the live MAC so their traffic is accepted.

Membership itself is persisted by the platform, which replays the whole joined set through this call when a session starts. Re-registering a channel already held is harmless.

Source

pub async fn remove_channels( &self, keys: Vec<Vec<u8>>, ) -> Result<(), MobileMeshError>

Drop channel keys from the live MAC, so its traffic is no longer decrypted. Idempotent, like Self::remove_peers.

Source

pub fn receive(&self, frame: MobileMeshRxRecord) -> Result<(), MobileMeshError>

Source

pub fn complete_outbound_frame( &self, frame_id: u64, transmitted: bool, ) -> Result<(), MobileMeshError>

Report the actual physical radio result for an outbound frame. This is intentionally distinct from accepting the frame into the BLE/CRP queue: the MAC starts ACK and retry timing only after success.

Source

pub async fn restore_chat( &self, checkpoints: Vec<MobileChatCheckpointRecord>, ) -> Result<(), MobileMeshError>

Source

pub async fn compose_text( &self, conversation_address: String, client_token: u32, body: String, ) -> Result<MobileChatComposeBatchRecord, MobileMeshError>

Compose a message into a conversation, addressed either by a peer’s address or by a channel’s conversation address.

Source

pub async fn compose_edit( &self, conversation_address: String, client_token: u32, original: MobileChatOriginalRef, body: String, ) -> Result<MobileChatComposeBatchRecord, MobileMeshError>

Compose an edit of a previously sent message. The original may come from an earlier app launch: its persisted (wire_id, epoch) is used when the facade session no longer holds a live handle, and the engine rejects it (ChatComposeFailed) if stream continuity was lost since.

Source

pub async fn compose_delete( &self, conversation_address: String, client_token: u32, original: MobileChatOriginalRef, ) -> Result<MobileChatComposeBatchRecord, MobileMeshError>

Compose a deletion (empty edit on the wire) of a previously sent message. Same original-reference rules as Self::compose_edit.

Source

pub async fn compose_reaction( &self, conversation_address: String, client_token: u32, target: MobileChatRegardingRef, body: String, ) -> Result<MobileChatComposeBatchRecord, MobileMeshError>

React to a message with a short emote body, or withdraw an earlier reaction by passing an empty body. A sender has at most one live reaction per message: sending another simply supersedes it, so there is nothing to edit or delete.

Unlike an edit, the target may be a message the peer sent, and usually one persisted before this launch; the reference carries the direction and (for channel groups) the sender hint needed to name it.

Source

pub async fn commit_chat_batch( &self, batch_id: u64, ) -> Result<(), MobileMeshError>

Source

pub async fn reject_chat_batch( &self, batch_id: u64, checkpoints: Vec<MobileChatCheckpointRecord>, ) -> Result<(), MobileMeshError>

Source

pub fn apply_chat_archive_result( &self, request_id: u32, kind: MobileChatArchiveResultKind, payload: Vec<u8>, ) -> Result<(), MobileMeshError>

Source

pub fn acknowledge_chat_batch( &self, batch_id: u64, ) -> Result<(), MobileMeshError>

Source

pub fn fail_outbound_transmissions(&self) -> Result<(), MobileMeshError>

Fail every chat transmission currently owned by the mobile radio bridge. The platform calls this when ULCP-link delivery failed after the MAC had accepted the frames, ensuring optimistic UI rows do not remain in Sending indefinitely.

Source

pub fn set_wake_listener(&self, listener: Arc<dyn MobileMeshWakeListener>)

Register (or replace) the listener that is told when this session has new data for poll_update. If data is already pending, the listener fires immediately.

Source

pub fn clear_wake_listener(&self)

Source

pub fn poll_update(&self) -> MobileMeshSessionUpdateRecord

Trait Implementations§

Source§

impl Drop for MobileMeshSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<UT> LiftRef<UT> for MobileMeshSession

Source§

impl<UT> LowerError<UT> for MobileMeshSession

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for MobileMeshSession

Source§

type ReturnType = <Arc<MobileMeshSession> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for MobileMeshSession

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
§

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

§

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
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.