Skip to main content

VariantProcessor

Trait VariantProcessor 

Source
pub trait VariantProcessor {
    type ProcessingOptions: BaseProcessingOptions;

    // Required methods
    fn get_valid_variants_for_content_type(
        content_type: &str,
    ) -> Vec<FileVariant>;
    fn get_content_type_for_variant(
        file: &FileDetails,
        variant: &FileVariant,
    ) -> String;
    fn get_options_for_variant(
        file: &FileDetails,
        variant: &FileVariant,
    ) -> Result<Self::ProcessingOptions, DynError>;
    fn process<'life0, 'life1, 'life2, 'async_trait>(
        origin_file_path: &'life0 str,
        output_file_path: &'life1 str,
        options: &'life2 Self::ProcessingOptions,
    ) -> Pin<Box<dyn Future<Output = Result<String, DynError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn create_variant<'life0, 'life1, 'async_trait>(
        file: &'life0 FileDetails,
        variant: &'life1 FileVariant,
        file_path: PathBuf,
    ) -> Pin<Box<dyn Future<Output = Result<String, DynError>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Required Associated Types§

Required Methods§

Source

fn get_valid_variants_for_content_type(content_type: &str) -> Vec<FileVariant>

Returns a list of valid variants for a given content type If there are no valid variants for the content type, return an empty list

Source

fn get_content_type_for_variant( file: &FileDetails, variant: &FileVariant, ) -> String

Returns the content type for a given variant

Source

fn get_options_for_variant( file: &FileDetails, variant: &FileVariant, ) -> Result<Self::ProcessingOptions, DynError>

Returns the processing options for a given variant If there are no options for this variant, return an error

Source

fn process<'life0, 'life1, 'life2, 'async_trait>( origin_file_path: &'life0 str, output_file_path: &'life1 str, options: &'life2 Self::ProcessingOptions, ) -> Pin<Box<dyn Future<Output = Result<String, DynError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Processes the origin file and saves the output to the output_file_path based on the passed options Returns the content type of the processed file or the original content type if no processing was done

Provided Methods§

Source

fn create_variant<'life0, 'life1, 'async_trait>( file: &'life0 FileDetails, variant: &'life1 FileVariant, file_path: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<String, DynError>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a variant for the given file If there are no options for this variant, return with the original content type

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§