BlockPipeline

Struct BlockPipeline 

Source
pub struct BlockPipeline { /* private fields */ }
Expand description

Pipeline for processing blocks through multiple middleware stages

§Example

use blocks::pipeline::BlockPipeline;

let pipeline = BlockPipeline::new()
    .add_middleware(|block| {
        block.content = block.content.trim().to_string();
        Ok(())
    })
    .add_middleware(|block| {
        block.content = block.content.to_uppercase();
        Ok(())
    });

Implementations§

Source§

impl BlockPipeline

Source

pub fn new() -> Self

Creates a new empty pipeline

Source

pub fn with_name(name: impl Into<String>) -> Self

Creates a new pipeline with a name

Source

pub fn add_middleware<F>(self, middleware: F) -> Self
where F: Fn(&mut Block) -> Result<()> + Send + Sync + 'static,

Adds a middleware function to the pipeline

Source

pub fn process(&self, block: &mut Block) -> Result<()>

Processes a block through all middleware in the pipeline

Source

pub fn process_all(&self, blocks: &mut [Block]) -> Result<()>

Processes multiple blocks through the pipeline

Source

pub fn name(&self) -> &str

Returns the pipeline name

Source

pub fn len(&self) -> usize

Returns the number of middleware in the pipeline

Source

pub fn is_empty(&self) -> bool

Returns true if the pipeline is empty

Trait Implementations§

Source§

impl Default for BlockPipeline

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.