Derive PartialOrd/Ord for Jid types

This commit is contained in:
xmppftw 2023-12-29 15:01:59 +01:00 committed by Link Mauve
parent e3fcdf1428
commit 141a40bc79
2 changed files with 4 additions and 4 deletions

View file

@ -27,7 +27,7 @@ fn length_check(len: usize, error_empty: Error, error_too_long: Error) -> Result
} }
} }
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub(crate) struct InnerJid { pub(crate) struct InnerJid {
pub(crate) normalized: String, pub(crate) normalized: String,
pub(crate) at: Option<NonZeroU16>, pub(crate) at: Option<NonZeroU16>,

View file

@ -54,7 +54,7 @@ pub use parts::{DomainPart, NodePart, ResourcePart};
/// An enum representing a Jabber ID. It can be either a `FullJid` or a `BareJid`. /// An enum representing a Jabber ID. It can be either a `FullJid` or a `BareJid`.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(untagged))] #[cfg_attr(feature = "serde", serde(untagged))]
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Jid { pub enum Jid {
/// Contains a [`BareJid`], without a resource part /// Contains a [`BareJid`], without a resource part
Bare(BareJid), Bare(BareJid),
@ -281,7 +281,7 @@ impl PartialEq<BareJid> for Jid {
/// Unlike a [`BareJid`], it always contains a resource, and should only be used when you are /// Unlike a [`BareJid`], it always contains a resource, and should only be used when you are
/// certain there is no case where a resource can be missing. Otherwise, use a [`Jid`] or /// certain there is no case where a resource can be missing. Otherwise, use a [`Jid`] or
/// [`BareJid`]. /// [`BareJid`].
#[derive(Clone, PartialEq, Eq, Hash)] #[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FullJid { pub struct FullJid {
inner: InnerJid, inner: InnerJid,
} }
@ -294,7 +294,7 @@ pub struct FullJid {
/// ///
/// Unlike a [`FullJid`], it cant contain a resource, and should only be used when you are certain /// Unlike a [`FullJid`], it cant contain a resource, and should only be used when you are certain
/// there is no case where a resource can be set. Otherwise, use a [`Jid`] or [`FullJid`]. /// there is no case where a resource can be set. Otherwise, use a [`Jid`] or [`FullJid`].
#[derive(Clone, PartialEq, Eq, Hash)] #[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct BareJid { pub struct BareJid {
inner: InnerJid, inner: InnerJid,
} }