jid: serde support for JID parts
This commit is contained in:
parent
58698f633f
commit
491264fe00
2 changed files with 10 additions and 0 deletions
|
@ -34,6 +34,8 @@ Version 0.11.1, release 2024-07-23:
|
||||||
- Fix clippy lints, cargo doc, and other warnings
|
- Fix clippy lints, cargo doc, and other warnings
|
||||||
- xso::FromXmlText and xso::AsXmlText are now implemented for NodePart,
|
- xso::FromXmlText and xso::AsXmlText are now implemented for NodePart,
|
||||||
DomainPart, and ResourcePart (!485)
|
DomainPart, and ResourcePart (!485)
|
||||||
|
- serde::Serialize and serde::Deserialize are now derived for NodePart,
|
||||||
|
DomainPart, and ResourcePart when serde feature flag is enabled (!499)
|
||||||
|
|
||||||
|
|
||||||
Version 0.11.0, release 2024-07-23 [YANKED]
|
Version 0.11.0, release 2024-07-23 [YANKED]
|
||||||
|
|
|
@ -6,6 +6,8 @@ use core::mem;
|
||||||
use core::ops::Deref;
|
use core::ops::Deref;
|
||||||
use core::str::FromStr;
|
use core::str::FromStr;
|
||||||
|
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use stringprep::{nameprep, nodeprep, resourceprep};
|
use stringprep::{nameprep, nodeprep, resourceprep};
|
||||||
|
|
||||||
use crate::{BareJid, Error, Jid};
|
use crate::{BareJid, Error, Jid};
|
||||||
|
@ -210,11 +212,13 @@ def_part_types! {
|
||||||
/// [`FullJid`][crate::FullJid].
|
/// [`FullJid`][crate::FullJid].
|
||||||
///
|
///
|
||||||
/// The corresponding slice type is [`NodeRef`].
|
/// The corresponding slice type is [`NodeRef`].
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct NodePart(String) use nodeprep(err = Error::NodePrep, empty = Error::NodeEmpty, long = Error::NodeTooLong);
|
pub struct NodePart(String) use nodeprep(err = Error::NodePrep, empty = Error::NodeEmpty, long = Error::NodeTooLong);
|
||||||
|
|
||||||
/// `str`-like type which conforms to the requirements of [`NodePart`].
|
/// `str`-like type which conforms to the requirements of [`NodePart`].
|
||||||
///
|
///
|
||||||
/// See [`NodePart`] for details.
|
/// See [`NodePart`] for details.
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||||
pub struct ref NodeRef(str);
|
pub struct ref NodeRef(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,23 +226,27 @@ def_part_types! {
|
||||||
/// The [`DomainPart`] is the part between the (optional) `@` and the
|
/// The [`DomainPart`] is the part between the (optional) `@` and the
|
||||||
/// (optional) `/` in any [`Jid`][crate::Jid], whether
|
/// (optional) `/` in any [`Jid`][crate::Jid], whether
|
||||||
/// [`BareJid`][crate::BareJid] or [`FullJid`][crate::FullJid].
|
/// [`BareJid`][crate::BareJid] or [`FullJid`][crate::FullJid].
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct DomainPart(String) use nameprep(err = Error::NamePrep, empty = Error::DomainEmpty, long = Error::DomainTooLong);
|
pub struct DomainPart(String) use nameprep(err = Error::NamePrep, empty = Error::DomainEmpty, long = Error::DomainTooLong);
|
||||||
|
|
||||||
/// `str`-like type which conforms to the requirements of [`DomainPart`].
|
/// `str`-like type which conforms to the requirements of [`DomainPart`].
|
||||||
///
|
///
|
||||||
/// See [`DomainPart`] for details.
|
/// See [`DomainPart`] for details.
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||||
pub struct ref DomainRef(str);
|
pub struct ref DomainRef(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
def_part_types! {
|
def_part_types! {
|
||||||
/// The [`ResourcePart`] is the optional part after the `/` in a
|
/// The [`ResourcePart`] is the optional part after the `/` in a
|
||||||
/// [`Jid`][crate::Jid]. It is mandatory in [`FullJid`][crate::FullJid].
|
/// [`Jid`][crate::Jid]. It is mandatory in [`FullJid`][crate::FullJid].
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct ResourcePart(String) use resourceprep(err = Error::ResourcePrep, empty = Error::ResourceEmpty, long = Error::ResourceTooLong);
|
pub struct ResourcePart(String) use resourceprep(err = Error::ResourcePrep, empty = Error::ResourceEmpty, long = Error::ResourceTooLong);
|
||||||
|
|
||||||
/// `str`-like type which conforms to the requirements of
|
/// `str`-like type which conforms to the requirements of
|
||||||
/// [`ResourcePart`].
|
/// [`ResourcePart`].
|
||||||
///
|
///
|
||||||
/// See [`ResourcePart`] for details.
|
/// See [`ResourcePart`] for details.
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||||
pub struct ref ResourceRef(str);
|
pub struct ref ResourceRef(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue