pub struct ModuleDescriptor { /* private fields */ }Expand description
A data structure that uniquely identifies an exact instance of a module
If two modules have the same ModuleDescriptor, they are considered to be the same module
The uid field encodes particulars about a module so it will never be mistaken for another copy or variation of the module even if the version field is the same. For example, a module loaded from the file system will use the uid to hash the path, while a module fetched from git will hash the url and branch.
Implementations§
Source§impl ModuleDescriptor
impl ModuleDescriptor
Sourcepub fn new(name: String, version: Option<Version>, uid: Option<u64>) -> Self
pub fn new(name: String, version: Option<Version>, uid: Option<u64>) -> Self
Create a new ModuleDescriptor
Sourcepub fn new_with_ident_bytes_and_fmt_id(
name: String,
version: Option<Version>,
ident: &[u8],
fmt_id: u64,
) -> Self
pub fn new_with_ident_bytes_and_fmt_id( name: String, version: Option<Version>, ident: &[u8], fmt_id: u64, ) -> Self
Returns a new ModuleDescriptor by computing a stable hash of the ident bytes, and using the fmt_id
Sourcepub fn new_with_path_and_fmt_id(
name: String,
version: Option<Version>,
path: &Path,
fmt_id: u64,
) -> Self
pub fn new_with_path_and_fmt_id( name: String, version: Option<Version>, path: &Path, fmt_id: u64, ) -> Self
Create a new ModuleDescriptor using a file system path and another unique id
The descriptor’s uid is based on a stable-hash of the path, because a module loaded by path shouldn’t be substituted for any other module unless it’s from the same path.
The purpose of the fmt_id is to ensure two different formats or catalogs don’t generate
the same ModuleDescriptor, but you can pass 0 if it doesn’t matter
Sourcepub fn version(&self) -> Option<&Version>
pub fn version(&self) -> Option<&Version>
Returns the version of the module represented by the ModuleDescriptor
Sourcepub fn hash(&self) -> u64
pub fn hash(&self) -> u64
Internal. Use the Hash trait to get a uid for the whole ModuleDescriptor
Sourcepub fn uid_from_ident_bytes_and_fmt_id(ident: &[u8], fmt_id: u64) -> u64
pub fn uid_from_ident_bytes_and_fmt_id(ident: &[u8], fmt_id: u64) -> u64
Returns a uid based on a stable hash of the ident bytes, and the fmt_id
Trait Implementations§
Source§impl Clone for ModuleDescriptor
impl Clone for ModuleDescriptor
Source§fn clone(&self) -> ModuleDescriptor
fn clone(&self) -> ModuleDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModuleDescriptor
impl Debug for ModuleDescriptor
Source§impl<'de> Deserialize<'de> for ModuleDescriptor
impl<'de> Deserialize<'de> for ModuleDescriptor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ModuleDescriptor
impl Display for ModuleDescriptor
Source§impl Hash for ModuleDescriptor
impl Hash for ModuleDescriptor
Source§impl PartialEq for ModuleDescriptor
impl PartialEq for ModuleDescriptor
Source§impl Serialize for ModuleDescriptor
impl Serialize for ModuleDescriptor
impl Eq for ModuleDescriptor
impl StructuralPartialEq for ModuleDescriptor
Auto Trait Implementations§
impl Freeze for ModuleDescriptor
impl RefUnwindSafe for ModuleDescriptor
impl Send for ModuleDescriptor
impl Sync for ModuleDescriptor
impl Unpin for ModuleDescriptor
impl UnwindSafe for ModuleDescriptor
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request