Trait Registry

Source
pub trait Registry {
    // Required methods
    fn get_base_url(&self) -> Url;
    fn get_update_path<C: Config>(&self, config: &C) -> String;
    fn get_basic_auth(&self) -> Result<Option<(String, Option<String>)>>;
}
Expand description

This trait is responsible to gives the base url for and the final path of the update json package description

Eg:

    use cli_autoupdate::{Config, Registry};
	struct MyRegistry
    impl Registry for MyRegistry {
		fn get_base_url(&self) -> Url {
			Url::parse("https://registry.example/").unwrap()
   		}
		fn get_update_path<C: Config>(&self, config: &C) -> String {
   			format!("{}.json", config.target())
   		}
		fn get_basic_auth(&self) -> anyhow::Result<Option<(String, Option<String>)>> {
			Ok(None)
		}
	}

Required Methods§

Source

fn get_base_url(&self) -> Url

base url of the repository. This is also used together with the RemoteVersion::path to create the final download url.

Source

fn get_update_path<C: Config>(&self, config: &C) -> String

This is the relative update json path, according to the configuration path.

Source

fn get_basic_auth(&self) -> Result<Option<(String, Option<String>)>>

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.

Implementors§