Skip to main content

Parser

Struct Parser 

Source
#[repr(C)]
pub struct Parser {
Show 36 fields pub autodetect: bool, pub is_request: bool, pub manage_unconsumed: bool, pub continue_without_data: bool, pub is_connect: bool, pub skip_body: bool, pub max_start_line_length: usize, pub max_header_length: usize, pub context: *mut c_void, pub debug: bool, pub state: u8, pub position: usize, pub parsed: u64, pub paused: bool, pub error_code: u8, pub method: u8, pub status: u32, pub version_major: u8, pub version_minor: u8, pub content_length: u64, pub chunk_size: u64, pub remaining_content_length: u64, pub remaining_chunk_size: u64, pub has_content_length: bool, pub has_transfer_encoding: bool, pub has_chunked_transfer_encoding: bool, pub has_connection_close: bool, pub has_connection_upgrade: bool, pub has_upgrade: bool, pub has_trailers: bool, pub active_callbacks: u64, pub callbacks: ParserCallbacks, pub error_description: *const c_uchar, pub error_description_len: u16, pub unconsumed: *const c_uchar, pub unconsumed_len: usize,
}

Fields§

§autodetect: bool§is_request: bool§manage_unconsumed: bool§continue_without_data: bool§is_connect: bool§skip_body: bool§max_start_line_length: usize§max_header_length: usize§context: *mut c_void§debug: bool§state: u8§position: usize§parsed: u64§paused: bool§error_code: u8§method: u8§status: u32§version_major: u8§version_minor: u8§content_length: u64§chunk_size: u64§remaining_content_length: u64§remaining_chunk_size: u64§has_content_length: bool§has_transfer_encoding: bool§has_chunked_transfer_encoding: bool§has_connection_close: bool§has_connection_upgrade: bool§has_upgrade: bool§has_trailers: bool§active_callbacks: u64§callbacks: ParserCallbacks§error_description: *const c_uchar§error_description_len: u16§unconsumed: *const c_uchar§unconsumed_len: usize

Implementations§

Source§

impl Parser

Source

pub fn parse(&mut self, input: *const c_uchar, limit: usize) -> usize

Parses a slice of characters.

It returns the number of consumed characters.

Source§

impl Parser

Source

pub fn new() -> Parser

Creates a new parser

Source

pub fn reset(&mut self, keep_parsed: bool)

Resets a parser. The second parameters specifies if to also reset the parsed counter.

The following fields are not modified:

  • position
  • context
  • autodetect
  • is_request
  • manage_unconsumed
  • continue_without_data
  • context
Source

pub fn clear(&mut self)

Clears all values about the message in the parser.

Source

pub fn pause(&mut self)

Pauses the parser. It will have to be resumed via resume.

Source

pub fn resume(&mut self)

Resumes the parser.

Source

pub fn finish(&mut self)

Marks the parser as finished. Any new data received via parse will put the parser in the error state.

Source

pub fn fail(&mut self, code: u8, description: &str)

Marks the parsing a failed, setting a error code and and error message.

It always returns zero for internal use.

Source

pub fn state_str(&self) -> &str

Returns the current parser’s state as string.

Source

pub fn error_code_str(&self) -> &str

Returns the current parser’s error state as string.

Source

pub fn error_description_str(&self) -> &str

Returns the current parser’s error description as string.

Trait Implementations§

Source§

impl Clone for Parser

Source§

fn clone(&self) -> Parser

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Parser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Parser

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.