pub struct Parser<R: Read> { /* private fields */ }Implementations§
Source§impl<R: Read> Parser<R>
impl<R: Read> Parser<R>
pub fn new(reader: R, buffer_size: usize) -> Self
pub fn with_dialect(reader: R, buffer_size: usize, dialect: SqlDialect) -> Self
Sourcepub fn with_limits(self, limits: ParserLimits) -> Self
pub fn with_limits(self, limits: ParserLimits) -> Self
Override the ParserLimits used by Parser::visit_events.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Total bytes currently buffered in memory. Used by tests to assert the event walker keeps its working set bounded even for huge INSERT/COPY blocks.
Sourcepub fn peak_buffered(&self) -> usize
pub fn peak_buffered(&self) -> usize
High-water mark of buffered bytes over this parser’s lifetime. Used by
tests to assert Parser::visit_events never buffers a whole multi-row
INSERT/COPY block.
pub fn read_statement(&mut self) -> Result<Option<Vec<u8>>>
Sourcepub fn visit_events<F>(&mut self, on_event: F) -> Result<()>
pub fn visit_events<F>(&mut self, on_event: F) -> Result<()>
Stream the input as ParserEvents with bounded memory.
Ordinary DDL/control statements are buffered whole (they are small) and
delivered as ParserEvent::Statement. A multi-row INSERT is delivered
as its header plus one ParserEvent::InsertRow per tuple, and a COPY
block as ParserEvent::CopyStart / ParserEvent::CopyRow per line /
ParserEvent::CopyEnd — the whole multi-row block is never buffered at
once. The callback must consume each borrowed slice before returning.
Unlike read_statement (kept for compatibility),
data statements are not routed through it: their rows are streamed.
pub fn parse_statement(stmt: &[u8]) -> (StatementType, String)
Sourcepub fn parse_statement_with_dialect(
stmt: &[u8],
dialect: SqlDialect,
) -> (StatementType, String)
pub fn parse_statement_with_dialect( stmt: &[u8], dialect: SqlDialect, ) -> (StatementType, String)
Parse a statement with dialect-specific handling
Auto Trait Implementations§
impl<R> Freeze for Parser<R>where
R: Freeze,
impl<R> RefUnwindSafe for Parser<R>where
R: RefUnwindSafe,
impl<R> Send for Parser<R>where
R: Send,
impl<R> Sync for Parser<R>where
R: Sync,
impl<R> Unpin for Parser<R>where
R: Unpin,
impl<R> UnsafeUnpin for Parser<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for Parser<R>where
R: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more