Skip to main content

BridgeServer

Struct BridgeServer 

Source
pub struct BridgeServer { /* private fields */ }

Implementations§

Source§

impl BridgeServer

Source

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.

Source

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.

Source

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.

Source

pub async fn command_raw( &self, payload: Value, timeout: Duration, ) -> Result<Value, BridgeError>

Send an unnamed command (payload-only) and await the first ack.

Source

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.

Source

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.

Source

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.

Source

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

Source

pub async fn wait_connected(&self)

Wait until at least one gauge connects.

Source

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.

Source

pub async fn clients(&self) -> Vec<ClientInfo>

List all currently connected clients.

Trait Implementations§

Source§

impl Clone for BridgeServer

Source§

fn clone(&self) -> BridgeServer

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

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
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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more