pub struct SlopServer { /* private fields */ }Expand description
SLOP server provider.
Manages node registrations, connections, and message routing.
Thread-safe — can be shared across threads via Clone (it wraps Arc).
§Example
use slop_ai::SlopServer;
use serde_json::json;
let mut slop = SlopServer::new("my-app", "My App");
slop.register("status", json!({"type": "status", "props": {"healthy": true}}));
assert_eq!(slop.version(), 1);Implementations§
Source§impl SlopServer
impl SlopServer
Sourcepub fn new(id: impl Into<String>, name: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, name: impl Into<String>) -> Self
Create a new SLOP server with the given provider ID and name.
Sourcepub fn register(&self, path: impl Into<String>, descriptor: Value)
pub fn register(&self, path: impl Into<String>, descriptor: Value)
Register a static node descriptor at path.
Sourcepub fn register_fn<F>(&self, path: impl Into<String>, f: F)
pub fn register_fn<F>(&self, path: impl Into<String>, f: F)
Register a descriptor function re-evaluated on refresh().
Sourcepub fn action<F>(
&self,
path: impl Into<String>,
name: impl Into<String>,
handler: F,
)
pub fn action<F>( &self, path: impl Into<String>, name: impl Into<String>, handler: F, )
Register an action handler at path/name.
Sourcepub fn action_with<F>(
&self,
path: impl Into<String>,
name: impl Into<String>,
handler: F,
options: ActionOptions,
)
pub fn action_with<F>( &self, path: impl Into<String>, name: impl Into<String>, handler: F, options: ActionOptions, )
Register an action handler with metadata (label, dangerous, etc.).
Sourcepub fn unregister(&self, path: &str)
pub fn unregister(&self, path: &str)
Remove the registration at path.
Sourcepub fn scope(&self, prefix: impl Into<String>) -> ScopedServer
pub fn scope(&self, prefix: impl Into<String>) -> ScopedServer
Return a scoped server that prefixes all paths.
Sourcepub fn handle_connection(&self, conn: Arc<dyn Connection>)
pub fn handle_connection(&self, conn: Arc<dyn Connection>)
Handle a new consumer connection.
Sourcepub fn emit_event(&self, name: &str, data: Option<Value>)
pub fn emit_event(&self, name: &str, data: Option<Value>)
Emit an event to all connected consumers.
Sourcepub fn handle_message(&self, conn: &Arc<dyn Connection>, msg: &Value)
pub fn handle_message(&self, conn: &Arc<dyn Connection>, msg: &Value)
Process an incoming message from a consumer.
Sourcepub fn handle_disconnect(&self, conn: &Arc<dyn Connection>)
pub fn handle_disconnect(&self, conn: &Arc<dyn Connection>)
Handle a consumer disconnect.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SlopServer
impl RefUnwindSafe for SlopServer
impl Send for SlopServer
impl Sync for SlopServer
impl Unpin for SlopServer
impl UnsafeUnpin for SlopServer
impl UnwindSafe for SlopServer
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