pub struct DogApp<R, P = ()>{ /* private fields */ }Expand description
DogApp is the central application container for DogRS.
Framework-agnostic. Holds:
- service registry
- app hooks
- per-service hooks
- config
Implementations§
Source§impl<R, P> DogApp<R, P>
impl<R, P> DogApp<R, P>
pub fn new() -> Self
pub fn register_service<S>(&self, name: S, service: Arc<dyn DogService<R, P>>)
Sourcepub fn hooks<F>(&self, f: F)where
F: FnOnce(&mut ServiceHooks<R, P>),
pub fn hooks<F>(&self, f: F)where
F: FnOnce(&mut ServiceHooks<R, P>),
Feathers: app.hooks({ ... })
Sourcepub fn service(&self, name: &str) -> Result<ServiceHandle<R, P>>
pub fn service(&self, name: &str) -> Result<ServiceHandle<R, P>>
Feathers: app.service("name")
Sourcepub fn set<K, V>(&self, key: K, value: V)
pub fn set<K, V>(&self, key: K, value: V)
Feathers: app.set(key, value) — now polymorphic.
- If value is a string (
&str/String), stores in config. - If value is
Arc<T>, stores in typed any-state.
Sourcepub fn get<T>(&self, key: &str) -> Option<T>where
T: FromAppValue,
pub fn get<T>(&self, key: &str) -> Option<T>where
T: FromAppValue,
Feathers: app.get(key) — now polymorphic via type inference.
let s: Option<String> = app.get("k");reads config.let db: Option<Arc<T>> = app.get("k");reads typed any-state.
pub fn config_snapshot(&self) -> DogConfigSnapshot
Source§impl<R, P> DogApp<R, P>
impl<R, P> DogApp<R, P>
Sourcepub fn on(
&self,
path: impl Into<String>,
event: ServiceEventKind,
listener: EventListener<R, P>,
)
pub fn on( &self, path: impl Into<String>, event: ServiceEventKind, listener: EventListener<R, P>, )
app.on(“messages”, ServiceEventKind::Created, Arc::new(|data, ctx| { /* … */ }));
pub fn on_str(&self, pattern: &str, listener: EventListener<R, P>) -> Result<()>
pub async fn emit_custom( &self, path: &str, event_name: impl Into<String>, payload: Arc<dyn Any + Send + Sync>, ctx: &HookContext<R, P>, )
pub fn publish(&self, f: PublishFn<R, P>)
pub fn clear_publish(&self)
Trait Implementations§
Auto Trait Implementations§
impl<R, P> Freeze for DogApp<R, P>
impl<R, P> RefUnwindSafe for DogApp<R, P>
impl<R, P> Send for DogApp<R, P>
impl<R, P> Sync for DogApp<R, P>
impl<R, P> Unpin for DogApp<R, P>
impl<R, P> UnwindSafe for DogApp<R, P>
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