lightspeed/transport/matrix
Transport profile matrix with progressive enhancement semantics for M24.
Types
Matrix adapter state.
pub type AdapterState {
AdapterState(
websocket: wisp_websocket.AdapterState,
profile: Profile,
mode: Mode,
queued_outbound: List(String),
last_client_sequence: Int,
last_client_seen_at_ms: Int,
security_policy: SecurityPolicy,
timeout_policy: TimeoutPolicy,
)
}
Constructors
-
AdapterState( websocket: wisp_websocket.AdapterState, profile: Profile, mode: Mode, queued_outbound: List(String), last_client_sequence: Int, last_client_seen_at_ms: Int, security_policy: SecurityPolicy, timeout_policy: TimeoutPolicy, )
Capability flags used by compatibility fixtures.
pub type Capability {
OrderedClientEvents
ReconnectSemantics
ServerPushFrames
BidirectionalChannel
ProgressiveFallback
}
Constructors
-
OrderedClientEvents -
ReconnectSemantics -
ServerPushFrames -
BidirectionalChannel -
ProgressiveFallback
Connect/reconnect request shape.
pub type ConnectRequest {
ConnectRequest(
route: String,
csrf_token: String,
origin: String,
now_ms: Int,
prefer_fallback: Bool,
)
}
Constructors
-
ConnectRequest( route: String, csrf_token: String, origin: String, now_ms: Int, prefer_fallback: Bool, )
Connect/reconnect result.
pub type ConnectResult {
Connected(state: AdapterState, outbound_frames: List(String))
Rejected(error: contract.AdapterError)
}
Constructors
-
Connected(state: AdapterState, outbound_frames: List(String)) -
Rejected(error: contract.AdapterError)
Active runtime mode.
pub type Mode {
PrimaryRealtime
FallbackPolling
}
Constructors
-
PrimaryRealtime -
FallbackPolling
Supported transport profiles for compatibility matrix testing.
pub type Profile {
WebSocketOnly
WebSocketWithServerSentEventsFallback
WebSocketWithLongPollingFallback
}
Constructors
-
WebSocketOnly -
WebSocketWithServerSentEventsFallback -
WebSocketWithLongPollingFallback
Receive/poll result.
pub type ReceiveResult {
ReceiveResult(
state: AdapterState,
outbound_frames: List(String),
)
}
Constructors
-
ReceiveResult(state: AdapterState, outbound_frames: List(String))
Security defaults enforced by matrix adapters.
pub type SecurityPolicy {
SecurityPolicy(
require_https_origin: Bool,
require_csrf: Bool,
max_payload_bytes: Int,
)
}
Constructors
-
SecurityPolicy( require_https_origin: Bool, require_csrf: Bool, max_payload_bytes: Int, )
Timeout defaults for heartbeat and reconnect behavior.
pub type TimeoutPolicy {
TimeoutPolicy(
heartbeat_timeout_ms: Int,
reconnect_grace_ms: Int,
)
}
Constructors
-
TimeoutPolicy(heartbeat_timeout_ms: Int, reconnect_grace_ms: Int)
Values
pub fn active_transport(
state: AdapterState,
) -> transport.Transport
Active transport for current profile+mode.
pub fn active_transport_label(state: AdapterState) -> String
Active transport label.
pub fn capability_enabled(
state: AdapterState,
capability: Capability,
) -> Bool
Capability predicate for fixtures and docs.
pub fn connect(
session_state: session.Session,
request: ConnectRequest,
profile: Profile,
auth_hook: contract.AuthHook,
) -> ConnectResult
Connect with default protection, security, and timeout policies.
pub fn connect_with_policies(
session_state: session.Session,
request: ConnectRequest,
profile: Profile,
auth_hook: contract.AuthHook,
protection_hook: contract.ProtectionHook,
security_policy: SecurityPolicy,
timeout_policy: TimeoutPolicy,
) -> ConnectResult
Connect with explicit protection, security, and timeout policies.
pub fn default_security_policy() -> SecurityPolicy
Default transport security policy.
pub fn fallback_available(profile: Profile) -> Bool
Whether the profile has a fallback mode available.
pub fn progressive_enhancement_active(
state: AdapterState,
) -> Bool
Whether fallback mode is active.
pub fn queued_outbound_count(state: AdapterState) -> Int
Number of queued frames pending poll.
pub fn receive(
state: AdapterState,
payload: String,
now_ms: Int,
client_sequence: Int,
) -> ReceiveResult
Receive one client frame.
client_sequence must be monotonically increasing per connection.
pub fn receive_with_hooks(
state: AdapterState,
payload: String,
now_ms: Int,
client_sequence: Int,
rate_limit_hook: contract.RateLimitHook,
) -> ReceiveResult
Receive one client frame with explicit rate-limit hook.
pub fn reconnect(
state: AdapterState,
request: ConnectRequest,
auth_hook: contract.AuthHook,
) -> ConnectResult
Reconnect with the state’s existing policy defaults.
pub fn reconnect_with_policies(
state: AdapterState,
request: ConnectRequest,
auth_hook: contract.AuthHook,
protection_hook: contract.ProtectionHook,
security_policy: SecurityPolicy,
timeout_policy: TimeoutPolicy,
) -> ConnectResult
Reconnect with explicit protection, security, and timeout policies.