StreamEffect

Trait StreamEffect 

Source
pub trait StreamEffect:
    'static
    + Send
    + Sync
    + Sized {
    type Input: 'static + Send + Sync;
    type Output: 'static + Send + Sync;

    // Required method
    fn side_effect(
        input: Self::Input,
        request: &mut StreamRequest<'_>,
    ) -> Result<Self::Output, OperationError>;
}
Expand description

You can create custom stream types that have side-effects, such as:

  • applying a transformation to the stream input to produce a different type of output
  • logging the message data
  • triggering an event or modifying a resource/component in the World

After you have implemented StreamEffect for your struct, you can apply #[derive(Stream)] to the struct and then use as a StreamPack, either on its own or in a tuple.

If you just want to stream a message with no side-effects, you can simply wrap your message type in StreamOf to get a StreamPack. Users only need to use StreamEffect if you want custom stream side-effects.

Required Associated Types§

Source

type Input: 'static + Send + Sync

Source

type Output: 'static + Send + Sync

Required Methods§

Source

fn side_effect( input: Self::Input, request: &mut StreamRequest<'_>, ) -> Result<Self::Output, OperationError>

Specify a side effect that is meant to happen whenever a stream value is sent.

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§