[−][src]Trait phpser::Source
Represents a data source for a Str
.
This is analogous to Read
,
except with arbitrary, potentially non-static return type S: Str
,
and provides methods optimized for usage in parsing.
Required methods
fn offset(&self) -> usize
Returns the number of bytes already read from the source.
fn limit(&self) -> usize
Returns the maximum possible number of bytes in the source.
This value is used for security reasons, to avoid out-of-memory error from arbitrarily large numbers as requested by the serialization.
fn read_u8_char(&mut self) -> IoResult<u8>
Reads one byte from the source.
Errors
If the byte is not an ASCII character,
this method returns Error::BadEncoding
.
If the source has already ended,
this method MUST return Error::UnexpectedEof
(instead of io::ErrorKind::UnexpectedEof
).
If an IO error occurs,
the error is returned directly wrapped in IoError::Io
.
fn read_str(&mut self, n: usize) -> IoResult<S>
Reads n
bytes from the source.
Errors
If the nth byte does ont terminate a character boundary,
this method should return Error::BadEncoding
.
If the source has less remaining characters available than n
,
this method MUST return Error::UnexpectedEof
(instead of io::ErrorKind::UnexpectedEof
).
If an IO error occurs,
the error is returned directly wrapped in IoError::Io
.
unsafe fn read_until(&mut self, byte: u8) -> IoResult<S>
Reads the source until the byte byte
.
This method consumes the slice before byte
AND byte
itself,
but only returns the slice before byte
.
Safety
byte
must be a valid ASCII character.
Implementations on Foreign Types
impl<'t, 'de, S, T> Source<'de, S> for &'t mut T where
S: Str<'de>,
T: Source<'de, S>,
[src]
S: Str<'de>,
T: Source<'de, S>,