[−][src]Trait phpser::Str
Represents a string of data, either owned or referenced.
The data can either be a raw byte string ([u8]
) or a UTF-8-checked string (str
),
and can be used either in the boxed type (Vec<u8>
/String
)
or as a reference ([u8]
/str
).
Safety
See the safety sections in each method.
Required methods
fn len(&self) -> usize
Gets the length of the string.
fn as_bytes(&self) -> &[u8]
Express the string as a slice of bytes
unsafe fn get_u8_char(&self, i: usize) -> Option<u8>
Gets the character at offset i
.
Returns None
if i+1
is not a boundary.
Safety
The offset i
must be a position that
the implementation previously inferred as a boundary
and less than the result of len()
.
The implementation must not return Some
unless i+1
is also a boundary.
unsafe fn clone_slice(&self, i: usize, j: usize) -> Option<Self>
Clones the characters from offset i
to offset j
.
Returns None
if j
is not a boundary.
Safety
The offset i
must be a position that
the implementation previously inferred as a boundary
i
and j
must be less than the result of len()
.
The implementation must not return Some
unless i+1
is also a boundary.
unsafe fn find(&self, i: usize, char: u8) -> Option<usize>
Finds the offset of the first occurrence of the ASCII character char
after (but not including) offset i
.
Safety
The offset i
should be a boundary,
although this does not affect the implementation
for UTF-8 strings.
i
must be less than the result of len()
.
char
must be an ASCII character.
If the returned value is Some
,
it must contain a boundary.
unsafe fn range_from(&self, i: usize) -> Self
Takes the subslice in bytes i..
.
Safety
The offset i
must be a boundary,
and hence must be <= self.len()
.
unsafe fn range(&self, i: usize, j: usize) -> Self
Takes the subslice in bytes i..j
.
Safety
The offsets i
and j
must be boundaries,
and hence must be <= self.len()
.