pub struct Services(/* private fields */);Expand description
An application-local handle. Obtain it from the constructor’s owner; child owners inherit the same services. Retained handles cannot revive a disposed app.
Implementations§
Source§impl Services
impl Services
pub fn from_owner(owner: &OwnerHandle) -> Result<Self, Error>
Sourcepub fn set_limits(&self, limits: ServiceLimits) -> Result<(), Error>
pub fn set_limits(&self, limits: ServiceLimits) -> Result<(), Error>
Configure bounds in the application constructor. Lowering a bound below current usage fails without changing any limit.
Sourcepub fn spawner(&self) -> impl Fn(LocalBoxFuture<'static, ()>) + 'static
pub fn spawner(&self) -> impl Fn(LocalBoxFuture<'static, ()>) + 'static
Adapter for fusor-async/query. Their futures retain their own cancellation and generation checks. Because their spawner cannot return an error, admission failure faults the runner instead of leaving a silent pending read.
Sourcepub fn spawn(
&self,
owner: &OwnerHandle,
future: impl Future<Output = ()> + 'static,
) -> Result<(), Error>
pub fn spawn( &self, owner: &OwnerHandle, future: impl Future<Output = ()> + 'static, ) -> Result<(), Error>
Spawn application work that stops being polled after owner disposal.
Sourcepub fn now(&self) -> Duration
pub fn now(&self) -> Duration
Monotonic elapsed time, suitable for a fusor-query clock closure.
Sourcepub fn sleep(&self, duration: Duration) -> Result<Sleep, Error>
pub fn sleep(&self, duration: Duration) -> Result<Sleep, Error>
Register a deadline without starting a thread. Dropping the future removes the deadline, including when a fusor request is cancelled.
Sourcepub fn worker<T: Send + 'static>(
&self,
cancel: &CancellationToken,
work: impl FnOnce(Arc<AtomicBool>) -> T + Send + 'static,
) -> Result<Worker<T>, Error>
pub fn worker<T: Send + 'static>( &self, cancel: &CancellationToken, work: impl FnOnce(Arc<AtomicBool>) -> T + Send + 'static, ) -> Result<Worker<T>, Error>
Run blocking work with an owned result and a cooperative cancellation flag. Only the closure, flag and result cross threads. No UI handles are Send. Cancellation cannot undo writes or forcibly stop arbitrary worker code.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Services
impl !Send for Services
impl !Sync for Services
impl !UnwindSafe for Services
impl Freeze for Services
impl Unpin for Services
impl UnsafeUnpin for Services
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more