pub struct ByteRange {
pub start: usize,
pub end: usize,
}Expand description
A half-open byte range [start, end) into canonical UTF-8 text.
Fields§
§start: usize§end: usizeImplementations§
Source§impl ByteRange
impl ByteRange
pub fn new(start: usize, end: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains(&self, other: &ByteRange) -> bool
Sourcepub fn validate(&self, text: &str) -> Result<(), RangeError>
pub fn validate(&self, text: &str) -> Result<(), RangeError>
Validates that the range is well-formed, inside text, and that both
boundaries lie on UTF-8 character boundaries.
This is the single gate through which every source mutation must pass (RFC-015 safety invariant: invalid UTF-8 boundary patches must be impossible).
Trait Implementations§
impl Copy for ByteRange
Source§impl<'de> Deserialize<'de> for ByteRange
impl<'de> Deserialize<'de> for ByteRange
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ByteRange
impl StructuralPartialEq for ByteRange
Auto Trait Implementations§
impl Freeze for ByteRange
impl RefUnwindSafe for ByteRange
impl Send for ByteRange
impl Sync for ByteRange
impl Unpin for ByteRange
impl UnsafeUnpin for ByteRange
impl UnwindSafe for ByteRange
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
Mutably borrows from an owned value. Read more