pub struct SqlStreamParser { /* private fields */ }Expand description
Streaming SQL statement parser
Parses SQL statements from a byte stream without loading all statements into memory. Uses a state machine to correctly handle quotes, escapes, and comments.
Implementations§
Source§impl SqlStreamParser
impl SqlStreamParser
Sourcepub async fn parse_file_from_index_collect(
&mut self,
file_path: &Path,
start_index: usize,
) -> Result<Vec<String>>
pub async fn parse_file_from_index_collect( &mut self, file_path: &Path, start_index: usize, ) -> Result<Vec<String>>
Parse SQL statements from a file, starting from a specific index
This is a convenience method that collects all statements into a Vec. For true streaming without memory accumulation, use parse_stream with a custom callback.
Sourcepub async fn parse_stream_collect<R>(
&mut self,
reader: R,
start_index: usize,
) -> Result<Vec<String>>
pub async fn parse_stream_collect<R>( &mut self, reader: R, start_index: usize, ) -> Result<Vec<String>>
Parse SQL statements from a reader with callback
Internal method kept for potential future streaming use cases Parse SQL statements from any async reader, collecting into a Vec
Sourcepub fn parse_line(&mut self, line: &str, out: &mut Vec<String>) -> Result<()>
pub fn parse_line(&mut self, line: &str, out: &mut Vec<String>) -> Result<()>
Parse a single line and push any completed statements into out.
Sourcepub fn count_line(&mut self, line: &str) -> usize
pub fn count_line(&mut self, line: &str) -> usize
Count completed statements in line WITHOUT allocating per statement.
Mirrors parse_line’s state machine exactly (quotes/brackets/escapes),
but instead of buffering bytes it tracks whether the in-progress
statement contains any non-whitespace byte, so a trailing ; on a
blank/whitespace-only buffer is not counted (parity with
take_trimmed_statement returning None on empty).
Sourcepub fn finish_count(&mut self) -> bool
pub fn finish_count(&mut self) -> bool
Mirror of finish_statement().is_some() for the count-only path.
Sourcepub fn finish_statement(&mut self) -> Option<String>
pub fn finish_statement(&mut self) -> Option<String>
Finalize parsing at EOF and return the remaining statement, if any
Auto Trait Implementations§
impl Freeze for SqlStreamParser
impl RefUnwindSafe for SqlStreamParser
impl Send for SqlStreamParser
impl Sync for SqlStreamParser
impl Unpin for SqlStreamParser
impl UnsafeUnpin for SqlStreamParser
impl UnwindSafe for SqlStreamParser
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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