Struct relm4::ShutdownReceiver

source ·
pub struct ShutdownReceiver { /* private fields */ }
Expand description

Listens to shutdown signals and constructs shutdown futures.

Implementations§

Create a future which will be cancelled on shutdown.

Examples found in repository?
src/channel/component.rs (line 116)
109
110
111
112
113
114
115
116
117
118
119
    pub fn oneshot_command<Fut>(&self, future: Fut)
    where
        Fut: Future<Output = CommandOutput> + Send + 'static,
    {
        // Async closures would be awesome here...
        self.command(move |out, shutdown| {
            shutdown
                .register(async move { out.send(future.await) })
                .drop_on_shutdown()
        });
    }

Waits until a shutdown signal is received.

Examples found in repository?
src/channel/shutdown/attached.rs (line 37)
34
35
36
37
38
39
40
41
42
43
44
45
    pub async fn wait(self) -> Either<(), Out> {
        let Self { receiver, future } = self;

        let cancel = receiver.wait();
        futures::pin_mut!(cancel);
        futures::pin_mut!(future);

        match futures::future::select(cancel, future).await {
            Either::Left(_) => Either::Left(()),
            Either::Right((out, _)) => Either::Right(out),
        }
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Returns the position. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Returns the position. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more