# control.ControlEvents

- **Module:** control
- **Package:** libtmux
- **Language:** Rust
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/control.rs#L1190
- **Page:** https://libtmux.org/en/rs/latest/reference/control-controlevents/

Receives tmux notifications and terminal connection errors.

This is a [`Stream<Item = Result<Event, Error>>`](Stream). Notifications
arrive in order. A connection failure follows all buffered notifications
as one `Err`; subsequent polls return `None`. A normal tmux `%exit` arrives
as [`Event::Exit`] and is followed by `None` after cleanup succeeds. EOF
without `%exit` is [`crate::ControlModeErrorKind::Closed`].
[`Server::shutdown`] may discard notifications still waiting for delivery
so an unread stream cannot prevent executor shutdown.

Exhaustion waits for connection cleanup. [`Self::shutdown`] closes early
and returns any terminal error the stream has not already delivered.

Events are buffered, and a consumer that stops reading eventually stops the
connection reading from tmux, which is the backpressure tmux already
expects from a slow client. During normal operation nothing is dropped;
commands wait instead. Drop this handle to opt out of events entirely and
the connection runs on.

## Members

- `next_event` (method): Return the next notification or terminal error, then `None`.
- `shutdown` (method): End the connection and report how it went.
