ModuleCatalog

Trait ModuleCatalog 

Source
pub trait ModuleCatalog:
    Debug
    + Send
    + Sync {
Show 13 methods // Required methods fn lookup(&self, name: &str) -> Vec<ModuleDescriptor>; fn get_loader( &self, descriptor: &ModuleDescriptor, ) -> Result<Box<dyn ModuleLoader>, String>; // Provided methods fn display_name(&self) -> String { ... } fn lookup_with_uid( &self, name: &str, uid: Option<u64>, ) -> Vec<ModuleDescriptor> { ... } fn lookup_with_version_req( &self, name: &str, version_req: Option<&VersionReq>, ) -> Vec<ModuleDescriptor> { ... } fn lookup_newest_with_version_req( &self, name: &str, version_req: Option<&VersionReq>, ) -> Option<ModuleDescriptor> { ... } fn lookup_newest_with_uid_and_version_req( &self, name: &str, uid: Option<u64>, version_req: Option<&VersionReq>, ) -> Option<ModuleDescriptor> { ... } fn list<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = ModuleDescriptor> + 'a>> { ... } fn list_names<'a>(&'a self) -> Option<Box<dyn Iterator<Item = String> + 'a>> { ... } fn list_name_uid_pairs<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = (String, Option<u64>)> + 'a>> { ... } fn as_any(&self) -> Option<&dyn Any> { ... } fn sync_toc(&self, _update_mode: UpdateMode) -> Result<(), String> { ... } fn as_managed(&self) -> Option<&dyn ManagedCatalog> { ... }
}
Expand description

Implemented for types capable of locating MeTTa modules

For example, ModuleCatalog would be an interface to a module respository, analogous to PyPI or crates.io but ModuleCatalog is also implemented for Path because any file system directory may be capable of storing and indexing MeTTa modules.

ModuleCatalog types are closely connected with ModuleLoader types because the ModuleCatalog must recognize the module in whatever media it exists, and supply the ModuleLoader to load that module

Required Methods§

Source

fn lookup(&self, name: &str) -> Vec<ModuleDescriptor>

Returns the ModuleDescriptor for every module in the ModuleCatalog with the specified name

Source

fn get_loader( &self, descriptor: &ModuleDescriptor, ) -> Result<Box<dyn ModuleLoader>, String>

Returns a ModuleLoader for the specified module from the ModuleCatalog

Provided Methods§

Source

fn display_name(&self) -> String

The name of the catalog, to be displayed to the user

Source

fn lookup_with_uid(&self, name: &str, uid: Option<u64>) -> Vec<ModuleDescriptor>

Returns the ModuleDescriptor for every module in the ModuleCatalog with the specified name, and uid match

Source

fn lookup_with_version_req( &self, name: &str, version_req: Option<&VersionReq>, ) -> Vec<ModuleDescriptor>

Returns the ModuleDescriptor for every module in the ModuleCatalog with the specified name matching the version requirements

NOTE: Unversioned modules will never match any version_req, so this method should never return any un-versioned ModuleDescriptors if version_req.is_some()

Source

fn lookup_newest_with_version_req( &self, name: &str, version_req: Option<&VersionReq>, ) -> Option<ModuleDescriptor>

Returns the ModuleDescriptor for the newest module in the ModuleCatalog, that matches the specified version requirement, or None if no module exists

If version_req == None, this method should return the newest module available in the catalog

NOTE: unversioned modules are considered to have the lowest possible version, and thus this method should only return an unversioned module if no matching modules are available NOTE: Unversioned modules will never match any version_req, so this method should never return any un-versioned ModuleDescriptors if version_req.is_some()

Source

fn lookup_newest_with_uid_and_version_req( &self, name: &str, uid: Option<u64>, version_req: Option<&VersionReq>, ) -> Option<ModuleDescriptor>

Returns the ModuleDescriptor for the newest module in the ModuleCatalog, that matches the specified name, uid, and version requirement, or None if no module exists

See ModuleCatalog::lookup_newest_with_version_req for more details

Source

fn list<'a>(&'a self) -> Option<Box<dyn Iterator<Item = ModuleDescriptor> + 'a>>

Returns an iterator over every module available in the catalog. May not be supported by all catalog implementations

Source

fn list_names<'a>(&'a self) -> Option<Box<dyn Iterator<Item = String> + 'a>>

Returns an iterator over every unique module name in the catalog. May not be supported by all catalog implementations

Source

fn list_name_uid_pairs<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = (String, Option<u64>)> + 'a>>

Returns an iterator over every unique (module name, uid) pair in the catalog. May not be supported by all catalog implementations

Source

fn as_any(&self) -> Option<&dyn Any>

Returns the catalog as an Any in order to get back to the underlying object

Source

fn sync_toc(&self, _update_mode: UpdateMode) -> Result<(), String>

Synchronize the catalog’s internal tables, so fresh upstream info is reflected locally. Does not fetch any modules

Source

fn as_managed(&self) -> Option<&dyn ManagedCatalog>

Returns the catalog as a ManagedCatalog if the catalog supports active management

Implementations§

Source§

impl dyn ModuleCatalog

Source

pub fn downcast<T: 'static>(&self) -> Option<&T>

Returns the catalog as as an underlying type, if it’s supported by the catalog format

Implementors§