Trait spirit_tokio::ResourceMaker[][src]

pub trait ResourceMaker<S, O, C, PipeThrough> where
    S: Borrow<ArcSwap<C>> + Sync + Send + 'static,
    C: Deserialize<'de> + Send + Sync + 'static,
    O: Debug + StructOpt + Sync + Send + 'static,
    Self: Sized
{ type Resource; type ExtraCfg: Clone + Debug + PartialEq + Send + 'static; fn apply<Extractor, ExtractedIter, Action, ActionFut, Name>(
        extractor: Extractor,
        action: Action,
        name: Name,
        builder: Builder<S, O, C>
    ) -> Builder<S, O, C>
    where
        Extractor: FnMut(&C) -> ExtractedIter + Send + 'static,
        ExtractedIter: IntoIterator<Item = (Self, PipeThrough)>,
        Action: Fn(&Arc<Spirit<S, O, C>>, Self::Resource, &Self::ExtraCfg, &PipeThrough) -> ActionFut + Send + Sync + 'static,
        ActionFut: IntoFuture<Item = (), Error = Error>,
        ActionFut::Future: Send + 'static,
        Name: Clone + Display + Send + Sync + 'static
; }

An alternative (more concrete) trait to IteratedCfgHelper for futures/tokio integration.

While the IteratedCfgHelper is good for end-user integration with extractors, there are too many loose ends to be usable to reuse in implementing composed helpers.

This has more concrete parts (specifically, it mandates that it produces only one specific type of something), so higher level abstractions can reuse lower-level builders. The current use case is being able to wrap the creator of TcpStream (or other streams, like possible SSL stream, Unix domain streams, etc) to be able to put something on top of them (a HTTP server, for example), regardless of what stream is used underneath.

Associated Types

The kind of resource the low-level thing builds.

This is, for example, the TCP stream.

Extra custom configuration carried in the config fragment.

This allows some data to be passed from the configuration to the provided action without interference by the maker. If not used, it can be ().

Required Methods

Installs the pipeline.

Similarly to helpers, this takes all the needed pieces and installs the pipeline to extract part of configuration, turn it into a resource, apply the user action and spawn the returned future into the builder.

Params

  • extractor: Closure that extracts a fragment from the configuration. This describe how the resource is created.
  • action: Something the user wants to be done with each created resource.
  • name: How the thing is called in the logs.
  • builder: The builder to modify.

Implementors