Skip to main content

TemplateSink

Trait TemplateSink 

Source
pub trait TemplateSink {
    type Error;

    // Required methods
    fn begin(&mut self, template: &SetTemplate) -> Result<(), Self::Error>;
    fn property(
        &mut self,
        path: &str,
        property: &PropertyTemplate,
    ) -> Result<(), Self::Error>;
    fn finish(&mut self, template: &SetTemplate) -> Result<(), Self::Error>;

    // Provided method
    fn quantity(
        &mut self,
        _quantity: &QuantityTemplate,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Adapter boundary for creating authored data from a catalog template.

A sink owns transactionality: if a callback fails, it must roll back any partial authored state itself.

Required Associated Types§

Source

type Error

Failure type raised by any callback; also the type the sink rolls back on.

Required Methods§

Source

fn begin(&mut self, template: &SetTemplate) -> Result<(), Self::Error>

Called once before any member callback for template. Sinks that open a transaction or authored-set shell should do it here.

Source

fn property( &mut self, path: &str, property: &PropertyTemplate, ) -> Result<(), Self::Error>

Called once per property in the template, path is the dotted ancestor chain for a nested Complex property (e.g. "Usage.Sub").

Source

fn finish(&mut self, template: &SetTemplate) -> Result<(), Self::Error>

Called once after every member callback for template has returned Ok.

Provided Methods§

Source

fn quantity(&mut self, _quantity: &QuantityTemplate) -> Result<(), Self::Error>

Called once per quantity in a quantity-set template. Default is a no-op, so sinks that only author property sets need not implement it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§