Skip to main content

rustsmb/io/
origin.rs

1//! Origin of an [`IoContext`](super::IoContext): whether it was triggered by a
2//! client request or by a server event, which decides if it carries a request
3//! payload and how its reply header is filled.
4
5mod sealed {
6    pub trait Sealed {}
7}
8
9/// Where an [`IoContext`](super::IoContext) came from. Sealed: the set of
10/// origins is closed to this crate. `Request` is the owned payload the context
11/// carries (`()` when there is none).
12pub trait Origin: sealed::Sealed {
13    /// The owned request payload for this origin.
14    type Request;
15}
16
17/// Triggered by a client frame; carries the parsed [`SmbRequest`](super::SmbRequest)
18/// and echoes the client's MessageId/SessionId/TreeId on reply.
19#[derive(Debug)]
20pub struct Solicited;
21
22/// A request-neutral context: the request has been split out to its handler, so
23/// the context carries only the shared bits and the reply header.
24#[derive(Debug)]
25pub struct Bare;
26
27/// Triggered by a server event (oplock/lease break, CHANGE_NOTIFY cleanup); has
28/// no request, and header fields are server-chosen ([MS-SMB2] ยง3.3.4.6).
29#[derive(Debug)]
30pub struct Unsolicited;
31
32impl sealed::Sealed for Solicited {}
33impl sealed::Sealed for Bare {}
34impl sealed::Sealed for Unsolicited {}
35
36impl Origin for Solicited {
37    type Request = super::SmbRequest;
38}
39impl Origin for Bare {
40    type Request = ();
41}
42impl Origin for Unsolicited {
43    type Request = ();
44}