fixup! add support for the imap quota extension (RFC 2087)
This commit is contained in:
parent
57ce6bb545
commit
9f7aedc8b0
1 changed files with 26 additions and 1 deletions
|
|
@ -35,7 +35,7 @@ impl Display for QuotaResourceLimit<'_> {
|
|||
/// From [Resources](https://datatracker.ietf.org/doc/html/rfc2087#section-3)
|
||||
///
|
||||
/// Used by [`QuotaLimit`], and [`QuotaResource`]
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub enum QuotaResourceName<'a> {
|
||||
/// Sum of messages' RFC822.SIZE, in units of 1024 octets
|
||||
|
|
@ -56,6 +56,17 @@ impl Display for QuotaResourceName<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> QuotaResourceName<'a> {
|
||||
/// Get an owned version of the [`QuotaResourceName`].
|
||||
pub fn into_owned(self) -> QuotaResourceName<'static> {
|
||||
match self {
|
||||
QuotaResourceName::Storage => QuotaResourceName::Storage,
|
||||
QuotaResourceName::Message => QuotaResourceName::Message,
|
||||
QuotaResourceName::Atom(n) => QuotaResourceName::Atom(Cow::Owned(n.into_owned())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// From [QUOTA Response](https://datatracker.ietf.org/doc/html/rfc2087#section-5.1)
|
||||
///
|
||||
/// This is a wrapper around a single single [`Quota`].
|
||||
|
|
@ -219,3 +230,17 @@ impl QuotaRootResponse {
|
|||
&self.borrow_inner().quotas[..]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_quota_resource_name_into_owned() {
|
||||
let name = "TEST";
|
||||
let borrowed = QuotaResourceName::Atom(Cow::Borrowed(name));
|
||||
|
||||
let new_owned = borrowed.into_owned();
|
||||
assert!(matches!(new_owned, QuotaResourceName::Atom(Cow::Owned(_))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue