Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions stun-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
//! - [`StunClient`](`crate::StunClient`): The STUN client that sends STUN requests and indications to a STUN server.
#![deny(missing_docs)]

use std::error::Error;
use std::fmt::Display;
use std::{ops::Deref, slice::Iter, sync::Arc};

use stun_rs::MessageHeader;
Expand Down Expand Up @@ -62,6 +64,30 @@ pub enum StunAgentError {
InternalError(String),
}

impl Display for StunAgentError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StunAgentError::Discarded => write!(f, "STUN agent has discarded the buffer"),
StunAgentError::FingerPrintValidationFailed => {
write!(f, "STUN agent has received an invalid STUN packet")
}
StunAgentError::Ignored => write!(f, "STUN agent has ignored the operation"),
StunAgentError::MaxOutstandingRequestsReached => write!(
f,
"STUN agent has reached the maximum number of outstanding requests"
),
StunAgentError::StunCheckFailed => {
write!(f, "STUN agent has received an invalid STUN packet")
}
StunAgentError::InternalError(msg) => {
write!(f, "STUN agent has detected an internal error: {}", msg)
}
}
}
}

impl Error for StunAgentError {}

/// Describes the kind of integrity protection that can be used.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Integrity {
Expand Down
Loading