Trait http_muncher::ParserHandler
[−]
[src]
pub trait ParserHandler: Sized { 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 { ... } }
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
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.
fn on_status(&mut self, &mut Parser, &[u8]) -> bool
Called when a response status becomes available.
It's not called in the request mode.
fn on_header_field(&mut self, &mut Parser, &[u8]) -> bool
Called for each HTTP header key part.
fn on_header_value(&mut self, &mut Parser, &[u8]) -> bool
Called for each HTTP header value part.
fn on_body(&mut self, &mut Parser, &[u8]) -> bool
Called with body text as an argument when the new part becomes available.
fn on_headers_complete(&mut self, &mut Parser) -> bool
Notified when all available headers have been processed.
fn on_message_begin(&mut self, &mut Parser) -> bool
Notified when the parser receives first bytes to parse.
fn on_message_complete(&mut self, &mut Parser) -> bool
Notified when the parser has finished its job.