Trait TemplateGenerator

Source
pub trait TemplateGenerator: TemplateLister {
    // Required methods
    fn generate_from_api(
        http_client: &impl HttpClient,
        endpoint_uri: Option<&str>,
        template_names: &[String],
    ) -> Result<String, ProgramExit>;
    fn generate_from_api_with_template_check(
        http_client: &impl HttpClient,
        generator_endpoint_uri: Option<&str>,
        lister_endpoint_uri: Option<&str>,
        template_names: &[String],
    ) -> Result<String, ProgramExit>;
}
Expand description

Template generator trait to generate a template via an API call made over HTTP.

Required Methods§

Source

fn generate_from_api( http_client: &impl HttpClient, endpoint_uri: Option<&str>, template_names: &[String], ) -> Result<String, ProgramExit>

Generates a string template matching given template names.

The template is generated via a GET API call made over HTTP using the given http client.

§Arguments
  • http_client - The http client to be used to make the API call.
  • endpoint_uri - The endpoint URI to generate templates (defaults to crate::constant::template_manager::GENERATOR_URI if None).
  • template_names - The template names to be used to generated the actual template.
§Returns

A result containing the generated template on success, or a ProgramExit on error (e.g. 4xx, network issues…).

Source

fn generate_from_api_with_template_check( http_client: &impl HttpClient, generator_endpoint_uri: Option<&str>, lister_endpoint_uri: Option<&str>, template_names: &[String], ) -> Result<String, ProgramExit>

Generates a string template matching given template names with robust template checks.

Behaves the same as TemplateGenerator::generate_from_api but will return a detailed error message in case any of provided template names are not listed in available template list (as returned by TemplateLister::list_from_api).

§Arguments
§Returns

A result containing the generated template on success, or a ProgramExit on error (e.g. 4xx, network issues, template not found…).

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§