Skip to main content

Crate teter_common

Crate teter_common 

Source
Expand description

Shared types and protocol definitions for teter.

This crate defines the wire protocol used between all three components: frontend, relay, and backend. Messages are JSON-encoded and framed by WebSocket text frames.

Re-exports§

pub use error::ProtocolError;
pub use error::ProtocolResult;

Modules§

account
The account protocol, on the relay’s /account path: one request, one reply, per connection (JSON text frames, like the rest of the protocol).
command
Commands from a device of the account to one of its machines (#88): to start or end a session, and later others.
error
Error types for the teter protocol.

Structs§

Message
A message sent between frontend, relay, and backend.

Enums§

MessagePayload
Type-specific payload for a Message.
MessageType
All message type identifiers known to the protocol.
Role
An authenticated connection role on the relay.

Constants§

BACKEND_LEFT
The session_error reason when the session’s backend left: the session is gone.
MAX_CHANNEL
The longest channel ID, in bytes.
MIN_PROTOCOL
The oldest relay protocol a relay of this build accepts from a client.
PROTOCOL
The relay protocol this build speaks (#95): the version of the messages between clients (backends, frontends) and the relay. A change a peer of the version before cannot follow raises it.
SESSION_GONE
The session_error reason when a frontend’s message finds its session already removed: the session is gone.

Functions§

check_protocol
Whether a relay that accepts min..=max serves a client of protocol client; the refusal names both and what to upgrade.
check_relay_protocol
Whether a client of this build works with a relay that speaks relay: a relay serves its version and the one before, so one older than this client is not.
deserialize_message
Deserialize a Message from a JSON string.
ends_the_session
Whether a session_error reason says the session itself ended, as opposed to an error about one connection or one message.
machine_proof_message
What a machine signs to answer a challenge: this prefix, the challenge, then its ID. The prefix keeps the signature from meaning anything else.
protocol_of
The relay protocol a first message json carries, read loosely before the message is decoded (#95): a newer client’s message may not decode here, and it still says what to upgrade.
serialize_message
Serialize a Message to a JSON string.
valid_channel
Whether channel can be a channel ID: 1 to MAX_CHANNEL ASCII letters or digits. Opaque: a backend picks it (a random ID per session), and it never holds a session’s name.

Type Aliases§

SessionId
Unique identifier for a teter session.