pub struct ServiceFactory {
pub name: &'static str,
pub factory: ServiceFactoryFn,
pub schema: Option<&'static [u8]>,
pub metadata: Option<SchemaMetadataFn>,
pub depends_on: &'static [&'static str],
}Expand description
Service factory for inventory-based registration.
Services register their factory function using #[service_factory("name")],
which generates an inventory::submit! for this type.
§Pattern
Same pattern as:
ScopeDefinitionwith#[register_scopes]for authorization scopesDriverFactoryin git2db for storage drivers
Fields§
§name: &'static strService name (matches config.services.startup entries)
factory: ServiceFactoryFnFactory function that creates the service
schema: Option<&'static [u8]>Raw .capnp schema bytes (compile-time embedded via include_bytes!)
metadata: Option<SchemaMetadataFn>Schema metadata function for compile-time scope discovery.
When set, returns (service_name, &[MethodMeta]) derived from Cap’n Proto
schema annotations. Used by PolicyService to discover supported scopes.
depends_on: &'static [&'static str]Names of services that must be started before this one.
Implementations§
Source§impl ServiceFactory
impl ServiceFactory
Sourcepub const fn new(name: &'static str, factory: ServiceFactoryFn) -> Self
pub const fn new(name: &'static str, factory: ServiceFactoryFn) -> Self
Create a new service factory (without schema).
Called by the #[service_factory] macro-generated code.
Sourcepub const fn with_schema(
name: &'static str,
factory: ServiceFactoryFn,
schema: &'static [u8],
) -> Self
pub const fn with_schema( name: &'static str, factory: ServiceFactoryFn, schema: &'static [u8], ) -> Self
Create a new service factory with schema bytes.
Called by the #[service_factory("name", schema = "...")] macro-generated code.
Sourcepub const fn with_metadata(
name: &'static str,
factory: ServiceFactoryFn,
schema: &'static [u8],
metadata: SchemaMetadataFn,
) -> Self
pub const fn with_metadata( name: &'static str, factory: ServiceFactoryFn, schema: &'static [u8], metadata: SchemaMetadataFn, ) -> Self
Create a new service factory with schema bytes and metadata.
Called by the #[service_factory("name", schema = "...", metadata = ...)] macro-generated code.
Sourcepub const fn with_depends_on(self, deps: &'static [&'static str]) -> Self
pub const fn with_depends_on(self, deps: &'static [&'static str]) -> Self
Set service dependencies (chained builder).
Services listed in depends_on must be started before this one.
Used by the #[service_factory("name", depends_on = ["policy"])] macro.
Trait Implementations§
impl Collect for ServiceFactory
Auto Trait Implementations§
impl Freeze for ServiceFactory
impl RefUnwindSafe for ServiceFactory
impl Send for ServiceFactory
impl Sync for ServiceFactory
impl Unpin for ServiceFactory
impl UnsafeUnpin for ServiceFactory
impl UnwindSafe for ServiceFactory
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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