pub struct Tacenta { /* private fields */ }Expand description
One tenant’s handle on one server: the API key, where the services are, and how the server is trusted. Cheap to clone; hold one per tenant.
Implementations§
Source§impl Tacenta
impl Tacenta
Sourcepub const DEFAULT_SERVER: &'static str = "tacenta.com"
pub const DEFAULT_SERVER: &'static str = "tacenta.com"
The hosted service.
Sourcepub async fn connect(api_key: &str) -> Result<Tacenta>
pub async fn connect(api_key: &str) -> Result<Tacenta>
Connect to hosted Tacenta: fetch its service document over HTTPS and trust its certificate through the public web PKI.
Sourcepub async fn connect_to(api_key: &str, server: &str) -> Result<Tacenta>
pub async fn connect_to(api_key: &str, server: &str) -> Result<Tacenta>
Connect to the Tacenta server at server (a host name), fetching
https://{server}/.well-known/tacenta with web-PKI trust.
Sourcepub async fn connect_via(
api_key: &str,
url: &str,
tls: &ClientTls,
) -> Result<Tacenta>
pub async fn connect_via( api_key: &str, url: &str, tls: &ClientTls, ) -> Result<Tacenta>
Connect by fetching the service document at an explicit URL, with
tls deciding the trust for an https:// URL. This is the local
development path (http://127.0.0.1:4780/.well-known/tacenta, the
gateway’s own port; http:// is accepted from loopback only) and the
path for a private certificate on the discovery host itself.
Sourcepub async fn fetch_document(
url: &str,
tls: &ClientTls,
) -> Result<ServiceDocument>
pub async fn fetch_document( url: &str, tls: &ClientTls, ) -> Result<ServiceDocument>
Fetch and parse the service document at url, without building a
handle: for a caller that caches documents. Pair it with
from_discovered.
Sourcepub async fn from_discovered(
api_key: &str,
url: &str,
doc: &ServiceDocument,
tls: &ClientTls,
) -> Result<Tacenta>
pub async fn from_discovered( api_key: &str, url: &str, doc: &ServiceDocument, tls: &ClientTls, ) -> Result<Tacenta>
Build a handle from a document fetched from url, holding the
document to what a document from that origin may say (see the module
documentation). connect_via is a fetch followed
by this.
Sourcepub async fn from_document(
api_key: &str,
doc: &ServiceDocument,
tls: &ClientTls,
) -> Result<Tacenta>
pub async fn from_document( api_key: &str, doc: &ServiceDocument, tls: &ClientTls, ) -> Result<Tacenta>
Build a handle from a service document already in hand, exactly as it
says. No origin check: the caller vouches for the document (it wrote
it, or fetched it and checked it). Resolves each host:port once;
tls is used when the document says web-PKI.
Sourcepub fn websocket(self) -> Result<Tacenta>
pub fn websocket(self) -> Result<Tacenta>
Reach the services over the document’s WebSocket carriage instead of their TCP ports: the path a browser or Node client takes, available to a native client too (to test it, or to cross a network that admits only HTTPS). Fails if the document offered no carriage.
Sourcepub fn with_connector(self, connector: Arc<dyn Connector>) -> Tacenta
pub fn with_connector(self, connector: Arc<dyn Connector>) -> Tacenta
Reach the services through streams connector opens, one per
service, ignoring the document’s addresses and carriage: the way a
host that owns the sockets (a browser page, a test harness) lends
them to the client.
Sourcepub fn is_websocket(&self) -> bool
pub fn is_websocket(&self) -> bool
Whether the services are reached over the WebSocket carriage.
Sourcepub fn websocket_url(&self) -> Option<&str>
pub fn websocket_url(&self) -> Option<&str>
The WebSocket base URL the document offered, if any.
Sourcepub fn from_endpoints(
api_key: &str,
endpoints: Endpoints,
trust: Option<(&str, &ClientTls)>,
) -> Tacenta
pub fn from_endpoints( api_key: &str, endpoints: Endpoints, trust: Option<(&str, &ClientTls)>, ) -> Tacenta
Build a handle from known endpoints: no discovery. trust is None
for a plaintext server, or the name the server’s certificate presents
with the trust to check it against (a pinned certificate, or
ClientTls::web_pki).
Sourcepub fn server_name(&self) -> Option<&str>
pub fn server_name(&self) -> Option<&str>
The name the server’s certificate presents; None for a plaintext
server.
Sourcepub async fn sign_up(&self, username: &str, password: &str) -> Result<()>
pub async fn sign_up(&self, username: &str, password: &str) -> Result<()>
Create a user in this tenant.
Sourcepub async fn sign_in(
&self,
username: &str,
password: &str,
) -> Result<DefaultClient>
pub async fn sign_in( &self, username: &str, password: &str, ) -> Result<DefaultClient>
Sign a user in on device 1 with a fresh device identity, returning a
connected client. Persist Client::export_state
and sign in again with sign_in_with_state
on later runs.
Sourcepub async fn sign_in_device(
&self,
username: &str,
password: &str,
device: u8,
) -> Result<DefaultClient>
pub async fn sign_in_device( &self, username: &str, password: &str, device: u8, ) -> Result<DefaultClient>
sign_in for a specific device number.
Sourcepub async fn sign_in_with_state(
&self,
username: &str,
password: &str,
device: u8,
state: &[u8],
) -> Result<DefaultClient>
pub async fn sign_in_with_state( &self, username: &str, password: &str, device: u8, state: &[u8], ) -> Result<DefaultClient>
Sign in resuming persisted state (identity and live sessions) from
Client::export_state.
Sourcepub async fn sign_in_with_state_sealed(
&self,
username: &str,
password: &str,
device: u8,
state: &[u8],
store: Arc<dyn SecureStore + Send + Sync>,
) -> Result<DefaultClient>
pub async fn sign_in_with_state_sealed( &self, username: &str, password: &str, device: u8, state: &[u8], store: Arc<dyn SecureStore + Send + Sync>, ) -> Result<DefaultClient>
Sign in resuming sealed state (from
Client::export_state_sealed)
with store attached: the rollback-resistant path (decision 0078,
anchor B). A forged state is refused, one older than the latest send
is caught by the store’s counter.