pub struct BridgeServer { /* private fields */ }Implementations§
Source§impl BridgeServer
impl BridgeServer
Sourcepub async fn start(config: ServerConfig) -> Result<Self, BridgeError>
pub async fn start(config: ServerConfig) -> Result<Self, BridgeError>
Start the bridge server and begin accepting connections.
This spawns a tokio task running the axum HTTP server.
The returned BridgeServer handle can be used to interact with
connected gauges.
Sourcepub fn router(config: ServerConfig) -> (Self, Router)
pub fn router(config: ServerConfig) -> (Self, Router)
Build an axum Router without starting a listener.
Useful when you want to mount the bridge as a nested route inside an existing axum application.
Sourcepub async fn command(
&self,
name: &str,
payload: Value,
timeout: Duration,
) -> Result<Value, BridgeError>
pub async fn command( &self, name: &str, payload: Value, timeout: Duration, ) -> Result<Value, BridgeError>
Send a named command to all connected gauges and await the first ack.
Sourcepub async fn command_raw(
&self,
payload: Value,
timeout: Duration,
) -> Result<Value, BridgeError>
pub async fn command_raw( &self, payload: Value, timeout: Duration, ) -> Result<Value, BridgeError>
Send an unnamed command (payload-only) and await the first ack.
Sourcepub async fn emit(
&self,
name: impl Into<String>,
data: Value,
) -> Result<(), BridgeError>
pub async fn emit( &self, name: impl Into<String>, data: Value, ) -> Result<(), BridgeError>
Send a fire-and-forget event to all connected gauges.
Returns Ok(()) if the event was dispatched to at least one gauge.
Returns Err(NoClients) if no gauges are connected.
Sourcepub fn subscribe_events(&self) -> Receiver<EventPayload>
pub fn subscribe_events(&self) -> Receiver<EventPayload>
Subscribe to events received from gauges.
Returns a broadcast receiver. Events are delivered as they arrive
from any connected gauge. If the receiver falls behind by
event_capacity messages, older events are dropped.
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Returns true if at least one gauge is connected.
An open socket only proves the relay is alive. Use Self::is_ready
when you need to know whether the module behind it can be reached.
Sourcepub async fn is_ready(&self) -> bool
pub async fn is_ready(&self) -> bool
Returns true if at least one connected gauge has reported its
downstream link bound (see infinity_bridge_wire::READY_EVENT).
Always false with relays that predate the ready event, so treat this
as a positive signal only — false means “not known to be reachable”.
Sourcepub async fn wait_connected(&self)
pub async fn wait_connected(&self)
Wait until at least one gauge connects.
Sourcepub fn connection_status(&self) -> Receiver<bool>
pub fn connection_status(&self) -> Receiver<bool>
Get a watch channel that tracks connection status.
The value is true when at least one gauge is connected,
false when all gauges have disconnected.
Sourcepub async fn clients(&self) -> Vec<ClientInfo>
pub async fn clients(&self) -> Vec<ClientInfo>
List all currently connected clients.
Trait Implementations§
Source§impl Clone for BridgeServer
impl Clone for BridgeServer
Source§fn clone(&self) -> BridgeServer
fn clone(&self) -> BridgeServer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more