pub unsafe trait SchemaReadContext<'de, C: ConfigCore, Ctx> {
type Dst;
const TYPE_META: TypeMeta = TypeMeta::Dynamic;
// Required method
fn read_with_context(
ctx: Ctx,
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()>;
// Provided method
fn get_with_context(
ctx: Ctx,
reader: impl Reader<'de>,
) -> ReadResult<Self::Dst> { ... }
}Expand description
Provided Associated Constants§
Sourceconst TYPE_META: TypeMeta = TypeMeta::Dynamic
const TYPE_META: TypeMeta = TypeMeta::Dynamic
Metadata about the type’s serialization.
§Safety
It is always safe to leave this as the default TypeMeta::Dynamic. If
you set it to TypeMeta::Static { size, zero_copy }, you have to ensure
the following two points:
sizemust always correspond to the number of bytes read byread.- If
zero_copyistrue,Dst’s in-memory representation must correspond exactly to the serialized form, and all byte sequences must be valid in-memory representations ofDst.
Required Associated Types§
Required Methods§
Sourcefn read_with_context(
ctx: Ctx,
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()>
fn read_with_context( ctx: Ctx, reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Read into dst from reader with context.
You must initialize dst if and only if you return Ok(()). In the
Err(…) case, initializing dst can lead to memory leaks.
It is permissible to not initialize dst if dst is an inhabited
zero-sized type.
Provided Methods§
Sourcefn get_with_context(ctx: Ctx, reader: impl Reader<'de>) -> ReadResult<Self::Dst>
fn get_with_context(ctx: Ctx, reader: impl Reader<'de>) -> ReadResult<Self::Dst>
Read Self::Dst from reader into a new Self::Dst with context.
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.
Implementations on Foreign Types§
Source§impl<'de, C: Config> SchemaReadContext<'de, C, Len> for String
Available on crate feature alloc only.
impl<'de, C: Config> SchemaReadContext<'de, C, Len> for String
Available on crate feature
alloc only.type Dst = String
fn read_with_context( ctx: Len, reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<'de, C: ConfigCore> SchemaReadContext<'de, C, Len> for &'de str
impl<'de, C: ConfigCore> SchemaReadContext<'de, C, Len> for &'de str
type Dst = &'de str
fn read_with_context( context::Len: Len, reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<'de, T, C: ConfigCore> SchemaReadContext<'de, C, Len> for &'de [T]where
T: SchemaRead<'de, C> + ZeroCopy<C>,
impl<'de, T, C: ConfigCore> SchemaReadContext<'de, C, Len> for &'de [T]where
T: SchemaRead<'de, C> + ZeroCopy<C>,
const TYPE_META: TypeMeta
type Dst = &'de [<T as SchemaRead<'de, C>>::Dst]
fn read_with_context( context::Len: Len, reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<'de, T, C: ConfigCore> SchemaReadContext<'de, C, Len> for Cow<'de, [T]>
Available on crate feature alloc only.
impl<'de, T, C: ConfigCore> SchemaReadContext<'de, C, Len> for Cow<'de, [T]>
Available on crate feature
alloc only.type Dst = Cow<'de, [T]>
fn read_with_context( ctx: Len, reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<'de, T, C: ConfigCore> SchemaReadContext<'de, C, Len> for Vec<T>where
T: SchemaRead<'de, C>,
Available on crate feature alloc only.
impl<'de, T, C: ConfigCore> SchemaReadContext<'de, C, Len> for Vec<T>where
T: SchemaRead<'de, C>,
Available on crate feature
alloc only.