smb_msg/
lib.rs

1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3#![allow(unused_parens)]
4
5pub mod cancel;
6pub mod compressed;
7pub mod create;
8pub mod dfsc;
9pub mod echo;
10pub mod encrypted;
11pub mod error;
12pub mod file;
13pub mod header;
14pub mod info;
15pub mod ioctl;
16pub mod lock;
17pub mod message;
18pub mod negotiate;
19pub mod notify;
20pub mod oplock;
21pub mod plain;
22pub mod query_dir;
23pub mod session_setup;
24pub mod smb1;
25pub mod tree_connect;
26
27pub use cancel::*;
28pub use compressed::*;
29pub use create::*;
30pub use dfsc::*;
31pub use echo::*;
32pub use encrypted::*;
33pub use error::*;
34pub use file::*;
35pub use header::*;
36pub use info::*;
37pub use ioctl::*;
38pub use lock::*;
39pub use message::*;
40pub use negotiate::*;
41pub use notify::*;
42pub use oplock::*;
43pub use plain::*;
44pub use query_dir::*;
45pub use session_setup::*;
46pub use tree_connect::*;
47
48#[cfg(test)]
49mod test;
50#[cfg(test)]
51use test::*;
52
53use thiserror::Error;
54/// SMB Message related errors
55#[derive(Error, Debug)]
56pub enum SmbMsgError {
57    #[error("Error code definition not found for NT Status code: {0:#x}")]
58    MissingErrorCodeDefinition(u32),
59
60    #[error("FSCTL definition not found for FSCTL code: {0:#x}")]
61    MissingFsctlDefinition(u32),
62
63    /// This error is returned when trying to get inner value of certain enum variant,
64    /// but the actual variant is different.
65    #[error("Unexpected content: {0} - expected {1}", actual, expected)]
66    UnexpectedContent {
67        actual: &'static str,
68        expected: &'static str,
69    },
70
71    #[error("Invalid data: {0}")]
72    InvalidData(String),
73
74    #[error("Invalid negotiate dialect cast to dialect: {0:?}")]
75    InvalidDialect(NegotiateDialect),
76
77    #[error("Binary read/write error: {0}")]
78    BinRWError(#[from] binrw::Error),
79}
80
81type Result<T> = std::result::Result<T, SmbMsgError>;