Struct imap_types::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
ext_literal
only.pub fn set_mode(&mut self, mode: LiteralMode)
ext_literal
only.pub fn into_sync(self) -> Self
ext_literal
only.pub fn into_non_sync(self) -> Self
ext_literal
only.pub fn into_inner(self) -> Cow<'a, [u8]>
sourcepub fn unvalidated<D>(data: D) -> Selfwhere
D: Into<Cow<'a, [u8]>>,
Available on crate feature unvalidated
only.
pub fn unvalidated<D>(data: D) -> Selfwhere D: Into<Cow<'a, [u8]>>,
unvalidated
only.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) -> Selfwhere D: Into<Cow<'a, [u8]>>,
ext_literal
and unvalidated
only.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<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self
from the given unstructured data. Read moresource§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 more