Skip to main content

ntex_io/
macros.rs

1/// Implements [`Filter::poll_ready`](crate::Filter::poll_ready) by forwarding
2/// the readiness check to a field.
3#[macro_export]
4macro_rules! forward_ready {
5    ($field:ident) => {
6        #[inline]
7        fn poll_ready(&self, cx: &mut std::task::Context<'_>) -> Poll<std::io::Result<()>> {
8            self.$field.poll_ready(cx)
9        }
10    };
11}
12
13#[macro_export]
14/// Implements [`Filter::query`](crate::Filter::query) by forwarding to a field.
15macro_rules! forward_query {
16    ($field:ident) => {
17        #[inline]
18        fn query(&self, id: std::any::TypeId) -> Option<Box<dyn std::any::Any>> {
19            self.$field.query(id)
20        }
21    };
22}
23
24#[macro_export]
25/// Implements [`Filter::shutdown`](crate::Filter::shutdown) by forwarding to a
26/// field.
27macro_rules! forward_shutdown {
28    ($field:ident) => {
29        #[inline]
30        fn shutdown(
31            &self,
32            ctx: &mut $crate::FilterCtx<'_>,
33        ) -> std::io::Result<std::task::Poll<()>> {
34            self.$field.shutdown(ctx)
35        }
36    };
37}