pub(crate) mod diff;
pub(crate) mod escaping;
pub(crate) mod request;
pub(crate) mod response;
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum ProtocolError {
#[error("tag `{tag}` requires {expected} arguments, found {found}")]
ArgumentCount {
tag: String,
expected: usize,
found: usize,
},
#[error("argument `{argument}` of tag `{tag}` is not a valid number: {value:?}")]
NotNumeric {
tag: String,
argument: &'static str,
value: String,
},
#[error("malformed percent-encoding at byte {position}: {reason}")]
Escaping {
position: usize,
reason: &'static str,
},
#[error("unrecognized notification tag `{tag}`")]
UnknownTag {
tag: String,
line: String,
},
#[error("cannot encode `{request}` request: {reason}")]
Request {
request: &'static str,
reason: String,
},
#[error("cannot decode field value: {reason}")]
FieldValue {
reason: String,
},
}
#[cold]
#[inline(never)]
pub(crate) fn field_value_error(reason: impl Into<String>) -> ProtocolError {
ProtocolError::FieldValue {
reason: reason.into(),
}
}