Generator

Trait Generator 

Source
pub trait Generator<Output: Serialize>: FromStr<Err = SimpleError> + Clone {
    // Required methods
    fn merge_with_default(self, default: Self) -> Self;
    fn generate(&self) -> Result<Output, SimpleError>;

    // Provided method
    fn encode(&self) -> Result<String, SimpleError> { ... }
}
Expand description

A trait that allows to generate complex objects from simple companion objects. A companion type should have a simple API, leaving most fields optional.

Required Methods§

Source

fn merge_with_default(self, default: Self) -> Self

Merge this companion with the another, default one. The options present in this object will override those in the default one.

Source

fn generate(&self) -> Result<Output, SimpleError>

Generate the complex object from this companion object.

Provided Methods§

Source

fn encode(&self) -> Result<String, SimpleError>

Generate and serialize the complex object

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§