Skip to main content

gproxy_protocol/
lib.rs

1//! GPROXY protocol types and endpoint metadata.
2//!
3//! The nested `protocol` module preserves the paths used before this code was
4//! split out of the main crate. The root re-exports keep the public API compact
5//! for downstream crates.
6
7pub mod protocol;
8
9pub use gproxy_protocol_macros::{WireBuilder, wire};
10pub use protocol::*;
11
12/// A required field was omitted while constructing a non-exhaustive wire
13/// struct through its generated builder.
14#[derive(Debug, Clone, PartialEq, Eq)]
15#[non_exhaustive]
16pub struct WireBuildError {
17    type_name: &'static str,
18    field: &'static str,
19}
20
21impl WireBuildError {
22    #[doc(hidden)]
23    pub const fn missing(type_name: &'static str, field: &'static str) -> Self {
24        Self { type_name, field }
25    }
26
27    pub const fn type_name(&self) -> &'static str {
28        self.type_name
29    }
30
31    pub const fn field(&self) -> &'static str {
32        self.field
33    }
34}
35
36impl std::fmt::Display for WireBuildError {
37    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38        write!(
39            formatter,
40            "missing required field `{}.{}`",
41            self.type_name, self.field
42        )
43    }
44}
45
46impl std::error::Error for WireBuildError {}