pub struct ServerState {
pub session: Arc<Mutex<Session>>,
pub ws_tx: Sender<String>,
}Expand description
Shared state accessible by all axum handlers.
Fields§
§session: Arc<Mutex<Session>>The agent session, protected by a mutex.
ws_tx: Sender<String>Broadcast sender for WebSocket fan-out.
Messages are JSON-serialized TuiMessage strings.
Implementations§
Source§impl ServerState
impl ServerState
Sourcepub fn new(session: Session, ws_tx: Sender<String>) -> Self
pub fn new(session: Session, ws_tx: Sender<String>) -> Self
Create new shared state from a session and broadcast sender.
Sourcepub fn spawn_drain_task(self, workflow_rx: UnboundedReceiver<TuiMessage>)
pub fn spawn_drain_task(self, workflow_rx: UnboundedReceiver<TuiMessage>)
Spawn a background task that owns the workflow receiver and broadcasts each message to all WebSocket subscribers.
The receiver is moved into the task — no locking needed to await it.
When a message arrives, the task briefly locks the session to call
handle_workflow_message, then broadcasts the JSON to WebSocket clients.
Trait Implementations§
Source§impl Clone for ServerState
impl Clone for ServerState
Source§fn clone(&self) -> ServerState
fn clone(&self) -> ServerState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ServerState
impl !UnwindSafe for ServerState
impl Freeze for ServerState
impl Send for ServerState
impl Sync for ServerState
impl Unpin for ServerState
impl UnsafeUnpin for ServerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more