#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum RawFormat {
Xml,
Json,
}
impl RawFormat {
pub fn as_etp(self) -> &'static str {
match self {
RawFormat::Xml => "xml",
RawFormat::Json => "json",
}
}
pub fn from_etp(word: &str) -> Option<Self> {
match word.to_ascii_lowercase().as_str() {
"xml" => Some(RawFormat::Xml),
"json" => Some(RawFormat::Json),
_ => None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct RawObject {
pub uri: String,
pub format: RawFormat,
pub bytes: Vec<u8>,
}
impl RawObject {
pub fn new(uri: impl Into<String>, format: RawFormat, bytes: Vec<u8>) -> Self {
Self {
uri: uri.into(),
format,
bytes,
}
}
}