Skip to main content

XmlSource

Struct XmlSource 

Source
pub struct XmlSource { /* private fields */ }
Expand description

Input source abstraction providing zero-allocation byte positioning and BOM auto-detection.

Implementations§

Source§

impl XmlSource

Source

pub const DEFAULT_MAX_STREAM_SIZE: usize

Default maximum byte limit for streaming readers (50 MB).

Source

pub fn from_string(xml: &str) -> Self

Creates an XmlSource from an in-memory string slice.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Creates an XmlSource from raw bytes, auto-detecting UTF-8/UTF-16 BOM markers.

Source

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.

Source

pub fn from_file(path: impl AsRef<Path>) -> Result<Self>

Reads an XmlSource from a file path on disk.

Source

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.

Source

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.

Source

pub fn format(&self) -> Format

Returns the detected encoding format.

Source

pub fn position(&self) -> usize

Returns the current character position byte index.

Source

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.

Source

pub fn len(&self) -> usize

Returns the total byte length of the underlying XML content.

Source

pub fn line(&self) -> usize

Returns the current 1-based line number.

Source

pub fn col(&self) -> usize

Returns the current 1-based column number.

Source

pub fn is_eof(&self) -> bool

Returns true if end of source buffer is reached.

Source

pub fn peek(&self) -> Option<char>

Peeks at the current character without advancing cursor position.

Source

pub fn peek_offset(&self, offset: usize) -> Option<char>

Peeks at character offset steps ahead.

Source

pub fn next_char(&mut self) -> Option<char>

Advances and returns the next character, updating line and column counters.

Source

pub fn starts_with(&self, prefix: &str) -> bool

Checks if source starts with expected prefix at current position.

Source

pub fn consume(&mut self, prefix: &str) -> bool

Consumes expected prefix string if present at current position.

Source

pub fn skip_whitespace(&mut self) -> usize

Skips all leading ASCII whitespace characters and returns the number of characters skipped.

Source

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 Clone for XmlSource

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for XmlSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ICharStream for XmlSource

Source§

fn next(&mut self)

Advances reading position to next character.
Source§

fn current(&mut self) -> Option<char>

Returns character at current position.
Source§

fn more(&mut self) -> bool

Checks if more characters are available.
Source§

impl ILocationAware for XmlSource

Source§

fn line(&self) -> usize

Returns 1-based line index.
Source§

fn column(&self) -> usize

Returns 1-based column index.
Source§

impl IPositionAware for XmlSource

Source§

fn position(&self) -> usize

Returns current absolute byte offset.
Source§

impl IRewindable for XmlSource

Source§

fn reset(&mut self)

Resets reading position to the beginning.
Source§

impl ISource for XmlSource

Source§

fn next(&mut self)

Advances reading position to next character.
Source§

fn current(&mut self) -> Option<char>

Returns character at current position.
Source§

fn more(&mut self) -> bool

Checks if more characters are available.
Source§

fn reset(&mut self)

Resets reading position to the beginning (default: no-op for forward-only streams).
Source§

fn can_rewind(&self) -> bool

Whether this source supports rewinding to the beginning.
Source§

impl IStatefulStream for XmlSource

Source§

fn save_state(&mut self) -> SaveState

Snapshots the source read position and metadata.
Source§

fn restore_state(&mut self, state: SaveState)

Restores a previously saved state.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> ICharReader for T
where T: ICharStream + ?Sized,

Source§

impl<T> ITracked for T

Source§

fn offset(&self) -> usize

Returns current absolute byte offset (delegates to IPositionAware::position).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.