tcplane/context/struct.rs
1use crate::*;
2
3/// Represents the internal state of the connection context.
4///
5/// This structure holds all the data associated with a single connection,
6/// including the stream, request, response, and any custom data.
7#[derive(Clone)]
8pub(crate) struct ContextData {
9 /// A flag indicating whether the connection handling has been aborted.
10 pub(crate) aborted: bool,
11 /// A flag indicating whether the connection has been closed.
12 pub(crate) closed: bool,
13 /// The underlying network stream for the connection.
14 pub(crate) stream: Option<ArcRwLockStream>,
15 /// The incoming request data.
16 pub(crate) request: Request,
17 /// The outgoing response.
18 pub(crate) response: Response,
19 /// Attributes storage for holding arbitrary type data during connection processing.
20 pub(crate) attributes: HashMapArcAnySendSync,
21}
22
23/// The main connection context, providing thread-safe access to connection data.
24///
25/// This is a wrapper around `ContextData` that uses an `Arc<RwLock<ContextData>>` to allow
26/// for shared, mutable access across asynchronous tasks.
27#[derive(Clone)]
28pub struct Context(pub(super) ArcRwLock<ContextData>);