use std::borrow::Cow;
use instant_xml::{FromXml, ToXml};
use crate::request::Extension;
pub(crate) const EPP_XMLNS: &str = "urn:ietf:params:xml:ns:epp-1.0";
#[derive(Debug, Eq, PartialEq, ToXml)]
pub struct NoExtension;
impl<'xml> FromXml<'xml> for NoExtension {
fn matches(_: instant_xml::Id<'_>, _: Option<instant_xml::Id<'_>>) -> bool {
false
}
fn deserialize<'cx>(
_: &mut Self::Accumulator,
_: &'static str,
_: &mut instant_xml::Deserializer<'cx, 'xml>,
) -> Result<(), instant_xml::Error> {
unreachable!()
}
type Accumulator = Option<Self>;
const KIND: instant_xml::Kind = instant_xml::Kind::Element;
}
impl Extension for NoExtension {
type Response = Self;
}
#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
#[xml(rename = "options", ns(EPP_XMLNS))]
pub struct Options<'a> {
pub version: Cow<'a, str>,
pub lang: Cow<'a, str>,
}
impl<'a> Options<'a> {
pub fn build(version: &'a str, lang: &'a str) -> Self {
Self {
version: version.into(),
lang: lang.into(),
}
}
}
#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
#[xml(rename = "svcExtension", ns(EPP_XMLNS))]
pub struct ServiceExtension<'a> {
#[xml(rename = "extURI")]
pub ext_uris: Vec<Cow<'a, str>>,
}
#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
#[xml(rename = "svcs", ns(EPP_XMLNS))]
pub struct Services<'a> {
#[xml(rename = "objURI")]
pub obj_uris: Vec<Cow<'a, str>>,
#[xml(rename = "svcExtension")]
pub svc_ext: Option<ServiceExtension<'a>>,
}
pub struct Certificate(pub Vec<u8>);
pub struct PrivateKey(pub Vec<u8>);