Trait ParserHandler

Source
pub trait ParserHandler: Sized {
    // Provided methods
    fn on_url(&mut self, _: &mut Parser, _: &[u8]) -> bool { ... }
    fn on_status(&mut self, _: &mut Parser, _: &[u8]) -> bool { ... }
    fn on_header_field(&mut self, _: &mut Parser, _: &[u8]) -> bool { ... }
    fn on_header_value(&mut self, _: &mut Parser, _: &[u8]) -> bool { ... }
    fn on_body(&mut self, _: &mut Parser, _: &[u8]) -> bool { ... }
    fn on_headers_complete(&mut self, _: &mut Parser) -> bool { ... }
    fn on_message_begin(&mut self, _: &mut Parser) -> bool { ... }
    fn on_message_complete(&mut self, _: &mut Parser) -> bool { ... }
    fn on_chunk_header(&mut self, _: &mut Parser) -> bool { ... }
    fn on_chunk_complete(&mut self, _: &mut Parser) -> bool { ... }
}
Expand description

Used to define a set of callbacks in your code. They would be called by the parser whenever new data is available. You should bear in mind that the data might get in your callbacks in a partial form.

Return bool as a result of each function call - either true for the “OK, go on” status, or false when you want to stop the parser after the function call has ended.

All callbacks provide a default no-op implementation (i.e. they just return true).

Provided Methods§

Source

fn on_url(&mut self, _: &mut Parser, _: &[u8]) -> bool

Called when the URL part of a request becomes available. E.g. for GET /forty-two HTTP/1.1 it will be called with "/forty_two" argument.

It’s not called in the response mode.

Source

fn on_status(&mut self, _: &mut Parser, _: &[u8]) -> bool

Called when a response status becomes available.

It’s not called in the request mode.

Source

fn on_header_field(&mut self, _: &mut Parser, _: &[u8]) -> bool

Called for each HTTP header key part.

Source

fn on_header_value(&mut self, _: &mut Parser, _: &[u8]) -> bool

Called for each HTTP header value part.

Source

fn on_body(&mut self, _: &mut Parser, _: &[u8]) -> bool

Called with body text as an argument when the new part becomes available.

Source

fn on_headers_complete(&mut self, _: &mut Parser) -> bool

Notified when all available headers have been processed.

Source

fn on_message_begin(&mut self, _: &mut Parser) -> bool

Notified when the parser receives first bytes to parse.

Source

fn on_message_complete(&mut self, _: &mut Parser) -> bool

Notified when the parser has finished its job.

Source

fn on_chunk_header(&mut self, _: &mut Parser) -> bool

Source

fn on_chunk_complete(&mut self, _: &mut Parser) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§