pub struct ServiceDefinitionLoader { /* private fields */ }Expand description
Loader rooted at one v2 service-definition directory.
Cheap to clone (PathBuf plus nothing else). Intended pattern:
construct once at broker startup, hold across the broker’s
lifetime, call Self::load per Hello message.
Implementations§
Source§impl ServiceDefinitionLoader
impl ServiceDefinitionLoader
Sourcepub fn default_root() -> Self
pub fn default_root() -> Self
Create a loader for the platform default v2 service-definition
directory (service_definition_dir_v2).
Sourcepub fn load(
&self,
service_name: &str,
) -> Result<ServiceDefinition, ServiceDefinitionError>
pub fn load( &self, service_name: &str, ) -> Result<ServiceDefinition, ServiceDefinitionError>
Load and validate one service definition from disk.
Re-reads the file on every call — matches v1’s reload-on-Hello semantics. Slow paths (validation, prost decode) live here so the broker’s accept loop stays allocation-free in the steady state.
§Errors
ServiceDefinitionError::InvalidNamewhenservice_namefails the shared validator.ServiceDefinitionError::InsecureDirectorywhenrootexists but has world/group write bits.ServiceDefinitionError::Iofor missing-file / permission / I/O failures.ServiceDefinitionError::Decodefor a corrupt or non-v2 servicedef file.ServiceDefinitionError::ServiceNameMismatchwhen the filename-derived service name doesn’t match the decodedservice_namefield — catches a typo’d or tampered file.
Sourcepub fn reload(
&self,
service_name: &str,
) -> Result<ServiceDefinition, ServiceDefinitionError>
pub fn reload( &self, service_name: &str, ) -> Result<ServiceDefinition, ServiceDefinitionError>
Sourcepub fn lookup_or_reload(
&self,
service_name: &str,
) -> Result<ServiceDefinition, ServiceDefinitionError>
pub fn lookup_or_reload( &self, service_name: &str, ) -> Result<ServiceDefinition, ServiceDefinitionError>
Lookup that always re-reads — mirrors v1’s lookup_or_reload.
Future caching can be inserted under this method without
changing the call-site contract.
§Errors
See Self::load.
Sourcepub fn enumerate(&self) -> Vec<ServiceDefinition>
pub fn enumerate(&self) -> Vec<ServiceDefinition>
Enumerate every parseable .servicedef.v2 file in the root.
Files that fail validation or decode are SKIPPED, not bubbled
— broker discovery wants the parseable subset, not a hard
failure on one corrupt entry. Use Self::scan when callers
need per-file error details.
Sourcepub fn scan(&self) -> Vec<ServiceDefinitionScanEntry>
pub fn scan(&self) -> Vec<ServiceDefinitionScanEntry>
Scan every .servicedef.v2 entry in the root with per-file errors.
Returns the entries sorted by path so the result is deterministic for snapshot tests + diff-friendly broker reflection APIs.
Trait Implementations§
Source§impl Clone for ServiceDefinitionLoader
impl Clone for ServiceDefinitionLoader
Source§fn clone(&self) -> ServiceDefinitionLoader
fn clone(&self) -> ServiceDefinitionLoader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServiceDefinitionLoader
impl RefUnwindSafe for ServiceDefinitionLoader
impl Send for ServiceDefinitionLoader
impl Sync for ServiceDefinitionLoader
impl Unpin for ServiceDefinitionLoader
impl UnsafeUnpin for ServiceDefinitionLoader
impl UnwindSafe for ServiceDefinitionLoader
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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