Skip to main content

Syntax

Struct Syntax 

Source
pub struct Syntax<const XML_NORMALIZED: bool = false> { /* private fields */ }
Expand description

Incremental allocation-free RFC2045 media-type syntax.

The default consumes original MIME octets and requires CRLF folding. XML_NORMALIZED = true additionally accepts XML’s already normalized LF. This does not resolve registered media types or compare their semantics.

use std::sync::Arc;
use structured_asn1::memory::{Memory, MemoryAccount};
use structured_cms::mime::Syntax;
let work = Memory::new(Arc::new(MemoryAccount::new(0, 1000)));
let mut value = Syntax::<false>::new();
assert!(value.feed("text/plain; charset=", &work).unwrap());
assert!(!value.complete());
assert!(value.feed("utf-8", &work).unwrap());
assert!(value.complete());

Implementations§

Source§

impl<const XML_NORMALIZED: bool> Syntax<XML_NORMALIZED>

Source

pub const fn new() -> Self

Begins a value without allocation or input work.

Source

pub fn feed<W: Work>( &mut self, value: impl AsRef<[u8]>, execution: &W, ) -> Result<bool, MemoryError>

Admits the whole fragment before changing state, then consumes it. Syntax failure is sticky across subsequent fragments. Resource failure leaves the state unchanged. Input may be borrowed str or byte slices.

Source

pub fn complete(&self) -> bool

A complete MIME value, with no open parameter, quote, comment or fold.

Trait Implementations§

Source§

impl<const XML_NORMALIZED: bool> Default for Syntax<XML_NORMALIZED>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const XML_NORMALIZED: bool> Freeze for Syntax<XML_NORMALIZED>

§

impl<const XML_NORMALIZED: bool> RefUnwindSafe for Syntax<XML_NORMALIZED>

§

impl<const XML_NORMALIZED: bool> Send for Syntax<XML_NORMALIZED>

§

impl<const XML_NORMALIZED: bool> Sync for Syntax<XML_NORMALIZED>

§

impl<const XML_NORMALIZED: bool> Unpin for Syntax<XML_NORMALIZED>

§

impl<const XML_NORMALIZED: bool> UnsafeUnpin for Syntax<XML_NORMALIZED>

§

impl<const XML_NORMALIZED: bool> UnwindSafe for Syntax<XML_NORMALIZED>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.