Skip to main content

Tacenta

Struct Tacenta 

Source
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

Source

pub const DEFAULT_SERVER: &'static str = "tacenta.com"

The hosted service.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_websocket(&self) -> bool

Whether the services are reached over the WebSocket carriage.

Source

pub fn websocket_url(&self) -> Option<&str>

The WebSocket base URL the document offered, if any.

Source

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).

Source

pub fn api_key(&self) -> &str

The tenant API key this handle carries.

Source

pub fn server_name(&self) -> Option<&str>

The name the server’s certificate presents; None for a plaintext server.

Source

pub fn endpoints(&self) -> &Endpoints

Where the four services are.

Source

pub fn is_tls(&self) -> bool

Whether connections are over TLS.

Source

pub async fn sign_up(&self, username: &str, password: &str) -> Result<()>

Create a user in this tenant.

Source

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.

Source

pub async fn sign_in_device( &self, username: &str, password: &str, device: u8, ) -> Result<DefaultClient>

sign_in for a specific device number.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Tacenta

Source§

fn clone(&self) -> Tacenta

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tacenta

Hand-written so the API key never reaches a log line: a {:?} on a handle shows where it points and how it trusts the server, and a redaction where the key would be.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V