pub struct Parser { /* private fields */ }Expand description
Reusable parser carrying the configured body size limit.
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn with_max_body_size(self, max_body_size: usize) -> Self
pub fn with_max_body_size(self, max_body_size: usize) -> Self
Override the body size limit. Zero is ignored so the default is kept.
Sourcepub fn parse_reader<R>(&self, reader: R) -> Result<Event, WebhookError>where
R: Read,
pub fn parse_reader<R>(&self, reader: R) -> Result<Event, WebhookError>where
R: Read,
Read at most max_body_size + 1 bytes from reader, then parse.
The extra byte is what lets us detect “body grew past the limit”
reliably: if the read came back with more than the limit, we know
the sender had more to give and reject with
WebhookError::BodyTooLarge before touching serde_json.
Sourcepub fn parse_bytes(&self, data: &[u8]) -> Result<Event, WebhookError>
pub fn parse_bytes(&self, data: &[u8]) -> Result<Event, WebhookError>
Parse data directly. Use this when you already have the body in
memory (e.g. a framework that buffered it for you).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnsafeUnpin for Parser
impl UnwindSafe for Parser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more