pub struct TicketMesh { /* private fields */ }Expand description
A ticket-scoped mesh on the caller’s existing Rust peer runtime.
The shared Client must already have an initialized Iroh endpoint. The
handle owns one ticket actor and borrows that runtime; it never creates a
second endpoint, durable device, or user-device connection owner.
Implementations§
Source§impl TicketMesh
impl TicketMesh
Sourcepub async fn issue(
client: Arc<Client>,
id: &str,
options: TicketMeshOptions,
) -> Result<Self>
pub async fn issue( client: Arc<Client>, id: &str, options: TicketMeshOptions, ) -> Result<Self>
Issue a transferable invitation. max_peers includes this issuer.
Sourcepub async fn join(client: Arc<Client>, invitation: &str) -> Result<Self>
pub async fn join(client: Arc<Client>, invitation: &str) -> Result<Self>
Join through the exact transferable bearer. Route recovery continues inside the Rust actor when the first dial encounters a dropped packet.
pub fn id(&self) -> &str
pub fn issuer_node(&self) -> Result<String>
Sourcepub fn watch_invite(&self) -> Receiver<String>
pub fn watch_invite(&self) -> Receiver<String>
Watch the current shareable invitation as its expiry-bound bearer renews.
Sourcepub fn watch_peers(&self) -> Receiver<Vec<PeerSessionSnapshot>>
pub fn watch_peers(&self) -> Receiver<Vec<PeerSessionSnapshot>>
The first value is the current settled, authenticated ticket peers.
Examples found in repository?
8async fn issue(client: Arc<Client>, share_id: &str) -> anyhow::Result<String> {
9 let mesh = TicketMesh::issue(client, share_id, TicketMeshOptions { max_peers: 8 }).await?;
10 let invite = mesh.invite();
11 let mut peers = mesh.watch_peers();
12 let _connected = peers.borrow_and_update().clone();
13 mesh.close().await;
14 Ok(invite)
15}
16
17async fn join(client: Arc<Client>, invite: &str) -> anyhow::Result<()> {
18 let mesh = TicketMesh::join(client, invite).await?;
19 let mut peers = mesh.watch_peers();
20 let _connected = peers.borrow_and_update().clone();
21 mesh.close().await;
22 Ok(())
23}Sourcepub async fn close(&self)
pub async fn close(&self)
Stop only this ticket actor. An issuer also revokes its admission grant; a guest revokes its local guest grant and leaves the issuer’s ticket.
Examples found in repository?
8async fn issue(client: Arc<Client>, share_id: &str) -> anyhow::Result<String> {
9 let mesh = TicketMesh::issue(client, share_id, TicketMeshOptions { max_peers: 8 }).await?;
10 let invite = mesh.invite();
11 let mut peers = mesh.watch_peers();
12 let _connected = peers.borrow_and_update().clone();
13 mesh.close().await;
14 Ok(invite)
15}
16
17async fn join(client: Arc<Client>, invite: &str) -> anyhow::Result<()> {
18 let mesh = TicketMesh::join(client, invite).await?;
19 let mut peers = mesh.watch_peers();
20 let _connected = peers.borrow_and_update().clone();
21 mesh.close().await;
22 Ok(())
23}