instant_epp/extensions/rgp/
mod.rs1use instant_xml::FromXml;
6
7pub mod poll; pub mod report;
9pub mod request;
10
11#[derive(Debug, PartialEq)]
12pub enum RgpStatus {
13 AddPeriod,
14 AutoRenewPeriod,
15 RenewPeriod,
16 TransferPeriod,
17 RedemptionPeriod,
18 PendingRestore,
19 PendingDelete,
20}
21
22impl<'xml> FromXml<'xml> for RgpStatus {
23 #[inline]
24 fn matches(id: ::instant_xml::Id<'_>, _: Option<::instant_xml::Id<'_>>) -> bool {
25 id == ::instant_xml::Id {
26 ns: XMLNS,
27 name: "rgpStatus",
28 } || id
29 == ::instant_xml::Id {
30 ns: poll::XMLNS,
31 name: "rgpStatus",
32 }
33 }
34
35 fn deserialize<'cx>(
36 into: &mut Self::Accumulator,
37 field: &'static str,
38 deserializer: &mut ::instant_xml::Deserializer<'cx, 'xml>,
39 ) -> Result<(), ::instant_xml::Error> {
40 use ::instant_xml::{Error, Id};
41 use instant_xml::de::Node;
42
43 let node = match deserializer.next() {
44 Some(result) => result?,
45 None => return Err(Error::MissingValue(field)),
46 };
47
48 let attr = match node {
49 Node::Attribute(attr) => attr,
50 Node::Open(_) | Node::Text(_) => return Err(Error::MissingValue(field)),
51 node => return Err(Error::UnexpectedNode(format!("{node:?} in RgpStatus"))),
52 };
53
54 let id = deserializer.attribute_id(&attr)?;
55 let expected = Id { ns: "", name: "s" };
56 if id != expected {
57 return Err(Error::MissingValue(field));
58 }
59
60 *into = Some(match attr.value.as_ref() {
61 "addPeriod" => Self::AddPeriod,
62 "autoRenewPeriod" => Self::AutoRenewPeriod,
63 "renewPeriod" => Self::RenewPeriod,
64 "transferPeriod" => Self::TransferPeriod,
65 "redemptionPeriod" => Self::RedemptionPeriod,
66 "pendingRestore" => Self::PendingRestore,
67 "pendingDelete" => Self::PendingDelete,
68 val => {
69 return Err(Error::UnexpectedValue(format!(
70 "invalid RgpStatus '{val:?}'"
71 )))
72 }
73 });
74
75 deserializer.ignore()?;
76 Ok(())
77 }
78
79 type Accumulator = Option<Self>;
80
81 const KIND: ::instant_xml::Kind = ::instant_xml::Kind::Element;
82}
83
84pub const XMLNS: &str = "urn:ietf:params:xml:ns:rgp-1.0";