pub struct XmlSource { /* private fields */ }Expand description
Input source abstraction providing zero-allocation byte positioning and BOM auto-detection.
Implementations§
Source§impl XmlSource
impl XmlSource
Sourcepub const DEFAULT_MAX_STREAM_SIZE: usize
pub const DEFAULT_MAX_STREAM_SIZE: usize
Default maximum byte limit for streaming readers (50 MB).
Sourcepub fn from_string(xml: &str) -> Self
pub fn from_string(xml: &str) -> Self
Creates an XmlSource from an in-memory string slice.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Creates an XmlSource from raw bytes, auto-detecting UTF-8/UTF-16 BOM markers.
Sourcepub fn from_bytes_with_encoding(bytes: &[u8], encoding: &str) -> Result<Self>
pub fn from_bytes_with_encoding(bytes: &[u8], encoding: &str) -> Result<Self>
Creates an XmlSource from raw bytes with an explicitly specified character encoding name.
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Reads an XmlSource from a file path on disk.
Sourcepub fn from_reader<R: Read>(reader: R) -> Result<Self>
pub fn from_reader<R: Read>(reader: R) -> Result<Self>
Reads all bytes from an arbitrary std::io::Read stream into an XmlSource,
enforcing the default safety limit of 50 MB to prevent unbounded memory allocation.
Sourcepub fn from_reader_with_limit<R: Read>(
reader: R,
max_bytes: usize,
) -> Result<Self>
pub fn from_reader_with_limit<R: Read>( reader: R, max_bytes: usize, ) -> Result<Self>
Reads all bytes from an arbitrary std::io::Read stream up to max_bytes.
Returns XmlError::SecurityLimitExceeded if the stream exceeds max_bytes.
Sourcepub fn slice_range(&self, start: usize, end: usize) -> &str
pub fn slice_range(&self, start: usize, end: usize) -> &str
Returns a string slice of the underlying content for a given byte range. Safely clamps and validates character boundaries to prevent indexing panics.
Sourcepub fn peek(&self) -> Option<char>
pub fn peek(&self) -> Option<char>
Peeks at the current character without advancing cursor position.
Sourcepub fn peek_offset(&self, offset: usize) -> Option<char>
pub fn peek_offset(&self, offset: usize) -> Option<char>
Peeks at character offset steps ahead.
Sourcepub fn next_char(&mut self) -> Option<char>
pub fn next_char(&mut self) -> Option<char>
Advances and returns the next character, updating line and column counters.
Sourcepub fn starts_with(&self, prefix: &str) -> bool
pub fn starts_with(&self, prefix: &str) -> bool
Checks if source starts with expected prefix at current position.
Sourcepub fn consume(&mut self, prefix: &str) -> bool
pub fn consume(&mut self, prefix: &str) -> bool
Consumes expected prefix string if present at current position.
Sourcepub fn skip_whitespace(&mut self) -> usize
pub fn skip_whitespace(&mut self) -> usize
Skips all leading ASCII whitespace characters and returns the number of characters skipped.
Sourcepub fn from_source(source: &mut dyn ISource) -> Self
pub fn from_source(source: &mut dyn ISource) -> Self
Creates an XmlSource by consuming an arbitrary character stream implementing babbel_core::io::traits::ISource.
Trait Implementations§
Source§impl ICharStream for XmlSource
impl ICharStream for XmlSource
Source§impl ILocationAware for XmlSource
impl ILocationAware for XmlSource
Source§impl IPositionAware for XmlSource
impl IPositionAware for XmlSource
Source§impl IRewindable for XmlSource
impl IRewindable for XmlSource
Source§impl ISource for XmlSource
impl ISource for XmlSource
Source§impl IStatefulStream for XmlSource
impl IStatefulStream for XmlSource
Source§fn save_state(&mut self) -> SaveState
fn save_state(&mut self) -> SaveState
Source§fn restore_state(&mut self, state: SaveState)
fn restore_state(&mut self, state: SaveState)
Auto Trait Implementations§
impl Freeze for XmlSource
impl RefUnwindSafe for XmlSource
impl Send for XmlSource
impl Sync for XmlSource
impl Unpin for XmlSource
impl UnsafeUnpin for XmlSource
impl UnwindSafe for XmlSource
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ICharReader for Twhere
T: ICharStream + ?Sized,
Source§impl<T> ITracked for T
impl<T> ITracked for T
Source§fn offset(&self) -> usize
fn offset(&self) -> usize
IPositionAware::position).