Rust
The client crate the CLI itself uses, and the surface every other head is generated from. If your service is already Rust this is the most direct path, and it is where the tenant handle arrived first.
Not on crates.io yet: depend on it from a checkout of the
tacenta repository.
Depend on it
[dependencies]
tacenta-client = { path = "../tacenta/crates/tacenta-client" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] } Send a message
use tacenta_client::Tacenta;
#[tokio::main]
async fn main() -> Result<(), tacenta_client::Error> {
let tenant = Tacenta::connect("tct_your_api_key").await?;
tenant.sign_up("alice", "correct horse").await?;
tenant.sign_up("bob", "correct horse").await?;
let mut alice = tenant.sign_in("alice", "correct horse").await?;
let mut bob = tenant.sign_in("bob", "correct horse").await?;
let to_bob = alice.find("bob").await?.expect("bob signed up");
alice.send(&to_bob.address, b"hello").await?;
for message in bob.receive().await? {
println!("{}: {:?}", message.from.user, message.plaintext);
}
Ok(())
} Tacenta::connect fetches the server's service document and
holds it to what a document from that origin may say; a self-hosted server
is Tacenta::connect_to(key, "chat.example.org"), and a local
development gateway is connect_via with its document URL.
bob.inbound() is the same messages as a Stream,
one at a time, and tacenta init rust writes this sample with
your key in place. A
client's export_state and the handle's
sign_in_with_state carry the identity and sessions across
runs; the sealed variants on Client resist rollback with a
SecureStore attached.
Over WebSockets, from Rust
The handle can take the same WebSocket carriage a browser does, useful for
checking a deployment's edge from a native client:
tenant.websocket()?, or TACENTA_TRANSPORT=websocket
for the CLI.
Reference
The generated reference, rustdoc of the client crate, regenerated at every release from the code it documents: tacenta.com/dl/reference/rust/tacenta_client/.