Connect hosts and guests
Mount the Rust runtime’s authenticated HTTP endpoints and scope access to a conversation.
Mount the router
Huggler::remote_router() returns an Axum router with POST /v1/peer and POST /v1/guest. The embedding host serves this router on loopback or behind a host-managed authenticated TLS transport. Send JSON and supply the bearer in the Authorization header. On the Rust client, remote::Peer::loopback accepts a loopback socket address, including a local tunnel endpoint.
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?;
let addr = listener.local_addr()?;
let router = huggler.remote_router();
let server = tokio::spawn(async move { axum::serve(listener, router).await });Keep the server handle in the host and arrange shutdown with the rest of the application. The example uses axum 0.8 and Tokio’s net feature.
Link two Huggler hosts
- On each host, call
address(&thread)for the thread you want to link. The address combines an environment ID and thread ID. - On the target host, use
approve_linkwith the target thread and sender address. Grantremote::Access::Readfor history and results orOperateto allow writes as well. - Transfer the returned bearer privately to the sender. Use
remote::Request::Readand its history cursor to page the target history, orRequest::Writeto send or delegate with an operating grant. Use the same sender run, key, and payload for an identical write retry. - Use
revoke_linkon the target host when access should end.
For owned work across hosts, call delegate_remote on the parent runtime and poll follow_remote for the result. The recorded remote child and follow-up survive a restart, and settlement wakes the parent once. The host drives polling and connectivity. Remote cancellation is unavailable.
Moderate guest submissions
- Call
invite_guestfor the thread. Give the guest its one-use invitation bearer. - The guest calls
guest::Request::Redeemwith a name. The response supplies a thread-scoped session bearer forViewandSubmit. - A submission enters
guest_inbox. Callmoderate_gueston the owning thread to accept it into the conversation or dismiss it. - Call
close_sharewith the invitation’s share ID to end guest access.