pub trait SizeWith<Ctx = ()> {
// Required method
fn size_with(ctx: &Ctx) -> usize;
}
Expand description
Gets the size of Self
with a Ctx
, and in Self::Units
. Implementors can then call Gread
related functions
The rationale behind this trait is to:
- Prevent
gread
from being used, and the offset being modified based on simply the sizeof the value, which can be a misnomer, e.g., for Leb128, etc. - Allow a context based size, which is useful for 32/64 bit variants for various containers, etc.
Required Methods§
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.