pub trait Service: Clone + 'static {
const NAME: &'static str;
// Provided methods
fn to_context(self) -> ServiceContext
where Self: Sized { ... }
fn layer(self) -> Layer<Self, Never, ()>
where Self: Sized { ... }
fn use_<A, E, R, F>(f: F) -> Effect<A, E, R>
where Self: Sized,
A: 'static,
E: From<MissingService> + 'static,
R: ServiceLookup<Self> + 'static,
F: FnOnce(Self) -> Effect<A, E, R> + 'static { ... }
fn use_sync<A, E, R, F>(f: F) -> Effect<A, E, R>
where Self: Sized,
A: 'static,
E: From<MissingService> + 'static,
R: ServiceLookup<Self> + 'static,
F: FnOnce(Self) -> A + 'static { ... }
}Expand description
Service marker implemented by #[derive(Service)].
A service type is both the key and the value stored in ServiceContext.
This intentionally mirrors Effect v4’s Context.Service class style while
staying Rust-native.
Required Associated Constants§
Provided Methods§
Sourcefn to_context(self) -> ServiceContextwhere
Self: Sized,
fn to_context(self) -> ServiceContextwhere
Self: Sized,
Wrap this service in a fresh ServiceContext.
Sourcefn layer(self) -> Layer<Self, Never, ()>where
Self: Sized,
fn layer(self) -> Layer<Self, Never, ()>where
Self: Sized,
Build a layer that provides this concrete service value.
Sourcefn use_<A, E, R, F>(f: F) -> Effect<A, E, R>where
Self: Sized,
A: 'static,
E: From<MissingService> + 'static,
R: ServiceLookup<Self> + 'static,
F: FnOnce(Self) -> Effect<A, E, R> + 'static,
fn use_<A, E, R, F>(f: F) -> Effect<A, E, R>where
Self: Sized,
A: 'static,
E: From<MissingService> + 'static,
R: ServiceLookup<Self> + 'static,
F: FnOnce(Self) -> Effect<A, E, R> + 'static,
Access this service and pass it to an effectful callback.
Sourcefn use_sync<A, E, R, F>(f: F) -> Effect<A, E, R>where
Self: Sized,
A: 'static,
E: From<MissingService> + 'static,
R: ServiceLookup<Self> + 'static,
F: FnOnce(Self) -> A + 'static,
fn use_sync<A, E, R, F>(f: F) -> Effect<A, E, R>where
Self: Sized,
A: 'static,
E: From<MissingService> + 'static,
R: ServiceLookup<Self> + 'static,
F: FnOnce(Self) -> A + 'static,
Access this service and pass it to a synchronous callback.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.