Struct imap_codec::core::AtomExt
source · pub struct AtomExt<'a>(_);
Expand description
A string subset to model IMAP’s 1*ASTRING-CHAR
(“extended atom
”).
This type is required due to the use of 1*ASTRING-CHAR
in astring
, see ABNF definition below.
Rules:
- Length must be >= 1
- Only some characters are allowed, e.g., no whitespace
ABNF definition
astring = 1*ASTRING-CHAR / string
; ^^^^^^^^^^^^^^
; |
; `AtomExt`
ASTRING-CHAR = ATOM-CHAR / resp-specials
; ^^^^^^^^^ ^^^^^^^^^^^^^
; | |
; | Additionally allowed in `AtomExt`
; See `Atom`
Implementations§
source§impl<'a> AtomExt<'a>
impl<'a> AtomExt<'a>
sourcepub fn validate(value: impl AsRef<[u8]>) -> Result<(), AtomExtError>
pub fn validate(value: impl AsRef<[u8]>) -> Result<(), AtomExtError>
Validates if value conforms to extended atom’s ABNF definition.
sourcepub fn into_inner(self) -> Cow<'a, str>
pub fn into_inner(self) -> Cow<'a, str>
Consumes the atom, returning the inner value.
sourcepub fn unvalidated<C>(inner: C) -> AtomExt<'a>where
C: Into<Cow<'a, str>>,
pub fn unvalidated<C>(inner: C) -> AtomExt<'a>where C: Into<Cow<'a, str>>,
Constructs an extended atom without validation.
Warning: IMAP conformance
The caller must ensure that inner
is valid according to Self::validate
. Failing to do
so may create invalid/unparsable IMAP messages, or even produce unintended protocol flows.
Do not call this constructor with untrusted data.
Trait Implementations§
source§impl<'a> Arbitrary<'a> for AtomExt<'a>
impl<'a> Arbitrary<'a> for AtomExt<'a>
source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<AtomExt<'a>, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<AtomExt<'a>, Error>
Generate an arbitrary value of
Self
from the given unstructured data. Read more§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self
from the entirety of the given
unstructured data. Read moresource§impl<'de, 'a> Deserialize<'de> for AtomExt<'a>
impl<'de, 'a> Deserialize<'de> for AtomExt<'a>
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<AtomExt<'a>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<AtomExt<'a>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a> IntoBoundedStatic for AtomExt<'a>
impl<'a> IntoBoundedStatic for AtomExt<'a>
source§fn into_static(self) -> <AtomExt<'a> as IntoBoundedStatic>::Static
fn into_static(self) -> <AtomExt<'a> as IntoBoundedStatic>::Static
Convert an owned
T
into an owned T
such that T: 'static
.source§impl<'a> PartialEq<AtomExt<'a>> for AtomExt<'a>
impl<'a> PartialEq<AtomExt<'a>> for AtomExt<'a>
source§impl<'a> Serialize for AtomExt<'a>
impl<'a> Serialize for AtomExt<'a>
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl<'a> ToBoundedStatic for AtomExt<'a>
impl<'a> ToBoundedStatic for AtomExt<'a>
impl<'a> Eq for AtomExt<'a>
impl<'a> StructuralEq for AtomExt<'a>
impl<'a> StructuralPartialEq for AtomExt<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for AtomExt<'a>
impl<'a> Send for AtomExt<'a>
impl<'a> Sync for AtomExt<'a>
impl<'a> Unpin for AtomExt<'a>
impl<'a> UnwindSafe for AtomExt<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more