Struct imap_codec::core::Literal
source · pub struct Literal<'a> { /* private fields */ }
Expand description
A sequence of zero or more (non-null) bytes prefixed with a length.
“A literal is a sequence of zero or more octets (including CR and LF), prefix-quoted with an octet count in the form of an open brace (”{“), the number of octets, close brace (”}“), and CRLF. In the case of literals transmitted from server to client, the CRLF is immediately followed by the octet data. In the case of literals transmitted from client to server, the client MUST wait to receive a command continuation request (…) before sending the octet data (and the remainder of the command).
Note: Even if the octet count is 0, a client transmitting a literal MUST wait to receive a command continuation request.“ (RFC 3501)
ABNF definition
literal = "{" number "}" CRLF *CHAR8
; Number represents the number of CHAR8s
number = 1*DIGIT
; Unsigned 32-bit integer
; (0 <= n < 4,294,967,296)
DIGIT = %x30-39
; 0-9
CRLF = CR LF
; Internet standard newline
CHAR8 = %x01-ff
; any OCTET except NUL, %x00
Implementations§
source§impl<'a> Literal<'a>
impl<'a> Literal<'a>
pub fn validate(value: impl AsRef<[u8]>) -> Result<(), LiteralError>
pub fn data(&self) -> &[u8] ⓘ
pub fn mode(&self) -> LiteralMode
pub fn set_mode(&mut self, mode: LiteralMode)
pub fn into_sync(self) -> Literal<'a>
pub fn into_non_sync(self) -> Literal<'a>
pub fn into_inner(self) -> Cow<'a, [u8]>
sourcepub fn unvalidated<D>(data: D) -> Literal<'a>where
D: Into<Cow<'a, [u8]>>,
pub fn unvalidated<D>(data: D) -> Literal<'a>where D: Into<Cow<'a, [u8]>>,
Constructs a literal without validation.
Warning: IMAP conformance
The caller must ensure that data
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.
pub fn unvalidated_non_sync<D>(data: D) -> Literal<'a>where D: Into<Cow<'a, [u8]>>,
Trait Implementations§
source§impl<'a> Arbitrary<'a> for Literal<'a>
impl<'a> Arbitrary<'a> for Literal<'a>
source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Literal<'a>, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Literal<'a>, Error>
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>
Self
from the entirety of the given
unstructured data. Read moresource§impl<'de, 'a> Deserialize<'de> for Literal<'a>
impl<'de, 'a> Deserialize<'de> for Literal<'a>
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Literal<'a>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Literal<'a>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
source§impl<'a> IntoBoundedStatic for Literal<'a>
impl<'a> IntoBoundedStatic for Literal<'a>
source§fn into_static(self) -> <Literal<'a> as IntoBoundedStatic>::Static
fn into_static(self) -> <Literal<'a> as IntoBoundedStatic>::Static
T
into an owned T
such that T: 'static
.