pub trait Offset:
Sealed
+ Copy
+ Eq
+ Ord
+ Debug
+ Send
+ Sync
+ 'static {
const TYPE_NAME: &'static str;
// Required methods
fn try_from_usize(value: usize) -> Option<Self>;
fn to_usize(self) -> usize;
}Expand description
Contract for integer types used as byte offsets.
Unlike crate::StringIndex (which bounds string count), Offset
bounds total UTF-8 byte size. Builders and validators use
Self::try_from_usize for checked growth, while lookup code uses
Self::to_usize for infallible slicing.
This trait is sealed and only implemented for unsigned integers that fit in
usize on the current target.
Required Associated Constants§
Required Methods§
Sourcefn try_from_usize(value: usize) -> Option<Self>
fn try_from_usize(value: usize) -> Option<Self>
Converts a byte length/offset into this type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.