rsip/headers/typed/
error_info.rs1#[doc(hidden)]
2pub use super::tokenizers::UriWithParamsListTokenizer as Tokenizer;
3
4use crate::common::uri::{UriWithParams, UriWithParamsList};
5use rsip_derives::TypedHeader;
6use std::convert::TryFrom;
7
8#[derive(TypedHeader, Eq, PartialEq, Clone, Debug)]
10pub struct ErrorInfo(pub UriWithParamsList);
11
12impl ErrorInfo {
13 pub fn uris(&self) -> &[UriWithParams] {
14 self.0.uris()
15 }
16}
17
18impl From<UriWithParamsList> for ErrorInfo {
19 fn from(uri_with_params_list: UriWithParamsList) -> Self {
20 Self(uri_with_params_list)
21 }
22}
23
24impl<'a> TryFrom<Tokenizer<'a>> for ErrorInfo {
25 type Error = crate::Error;
26
27 fn try_from(tokenizer: Tokenizer) -> Result<Self, Self::Error> {
28 Ok(Self(UriWithParamsList::try_from(tokenizer)?))
29 }
30}
31
32impl std::fmt::Display for ErrorInfo {
33 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34 write!(f, "{}", self.0)
35 }
36}