Trait thin::DynSized
[−]
[src]
pub unsafe trait DynSized { type Meta: Copy; fn assemble(meta: Self::Meta, data: *const ()) -> *const Self; fn disassemble(ptr: *const Self) -> (Self::Meta, *const ()); fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self { ... } fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ()) { ... } fn meta(&self) -> Self::Meta { ... } fn data(&self) -> *const () { ... } fn data_mut(&mut self) -> *mut () { ... } }
A trait for dynamically sized types, similar in principle to the Sized
trait. Allows conversion between fat and thin pointers.
The assemble and disassemble methods must be safe, i.e. they must not dereference the raw pointers, only use them to extract the metadata in the case of disassemble
, or to combine with metadata to produce a fat pointer, in the case of assemble
.
Unsafety
The trait is marked unsafe
, because implementing it wrong can cause undefined behaviour.
Associated Types
Required Methods
fn assemble(meta: Self::Meta, data: *const ()) -> *const Self
fn disassemble(ptr: *const Self) -> (Self::Meta, *const ())
Provided Methods
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
fn meta(&self) -> Self::Meta
fn data(&self) -> *const ()
fn data_mut(&mut self) -> *mut ()
Implementations on Foreign Types
impl<'a, Args, Output> DynSized for FnMut<Args, Output = Output> + 'a + Send
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const FnMut<Args, Output = Output> + 'a + Send
[src]
vtable: Vtable,
data: *const ()
) -> *const FnMut<Args, Output = Output> + 'a + Send
fn disassemble(
ptr: *const FnMut<Args, Output = Output> + 'a + Send
) -> (<FnMut<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
[src]
ptr: *const FnMut<Args, Output = Output> + 'a + Send
) -> (<FnMut<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for FnMut<Args, Output = Output> + 'a
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const FnMut<Args, Output = Output> + 'a
[src]
vtable: Vtable,
data: *const ()
) -> *const FnMut<Args, Output = Output> + 'a
fn disassemble(
ptr: *const FnMut<Args, Output = Output> + 'a
) -> (<FnMut<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
[src]
ptr: *const FnMut<Args, Output = Output> + 'a
) -> (<FnMut<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl DynSized for Any + 'static
[src]
type Meta = Vtable
fn assemble(vtable: Vtable, data: *const ()) -> *const Any + 'static
[src]
fn disassemble(
ptr: *const Any + 'static
) -> (<Any + 'static as DynSized>::Meta, *const ())
[src]
ptr: *const Any + 'static
) -> (<Any + 'static as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<T> DynSized for [T]
[src]
type Meta = usize
fn assemble(len: usize, data: *const ()) -> *const [T]
[src]
fn disassemble(slice: *const [T]) -> (usize, *const ())
[src]
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for Fn<Args, Output = Output> + 'a + Send + Sync
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a + Send + Sync
[src]
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a + Send + Sync
fn disassemble(
ptr: *const Fn<Args, Output = Output> + 'a + Send + Sync
) -> (<Fn<Args, Output = Output> + 'a + Send + Sync as DynSized>::Meta, *const ())
[src]
ptr: *const Fn<Args, Output = Output> + 'a + Send + Sync
) -> (<Fn<Args, Output = Output> + 'a + Send + Sync as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl DynSized for str
[src]
type Meta = usize
fn assemble(len: usize, data: *const ()) -> *const str
[src]
fn disassemble(s: *const str) -> (usize, *const ())
[src]
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for FnOnce<Args, Output = Output> + 'a + Send
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const FnOnce<Args, Output = Output> + 'a + Send
[src]
vtable: Vtable,
data: *const ()
) -> *const FnOnce<Args, Output = Output> + 'a + Send
fn disassemble(
ptr: *const FnOnce<Args, Output = Output> + 'a + Send
) -> (<FnOnce<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
[src]
ptr: *const FnOnce<Args, Output = Output> + 'a + Send
) -> (<FnOnce<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for Fn<Args, Output = Output> + 'a + Sync
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a + Sync
[src]
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a + Sync
fn disassemble(
ptr: *const Fn<Args, Output = Output> + 'a + Sync
) -> (<Fn<Args, Output = Output> + 'a + Sync as DynSized>::Meta, *const ())
[src]
ptr: *const Fn<Args, Output = Output> + 'a + Sync
) -> (<Fn<Args, Output = Output> + 'a + Sync as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl DynSized for Any + 'static + Send
[src]
type Meta = Vtable
fn assemble(vtable: Vtable, data: *const ()) -> *const Any + 'static + Send
[src]
fn disassemble(
ptr: *const Any + 'static + Send
) -> (<Any + 'static + Send as DynSized>::Meta, *const ())
[src]
ptr: *const Any + 'static + Send
) -> (<Any + 'static + Send as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for Fn<Args, Output = Output> + 'a + Send
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a + Send
[src]
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a + Send
fn disassemble(
ptr: *const Fn<Args, Output = Output> + 'a + Send
) -> (<Fn<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
[src]
ptr: *const Fn<Args, Output = Output> + 'a + Send
) -> (<Fn<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for Fn<Args, Output = Output> + 'a
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a
[src]
vtable: Vtable,
data: *const ()
) -> *const Fn<Args, Output = Output> + 'a
fn disassemble(
ptr: *const Fn<Args, Output = Output> + 'a
) -> (<Fn<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
[src]
ptr: *const Fn<Args, Output = Output> + 'a
) -> (<Fn<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<T> DynSized for WrapSized<T>
[src]
type Meta = ()
fn assemble((), data: *const ()) -> *const WrapSized<T>
[src]
fn disassemble(ptr: *const WrapSized<T>) -> ((), *const ())
[src]
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for FnOnce<Args, Output = Output> + 'a
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const FnOnce<Args, Output = Output> + 'a
[src]
vtable: Vtable,
data: *const ()
) -> *const FnOnce<Args, Output = Output> + 'a
fn disassemble(
ptr: *const FnOnce<Args, Output = Output> + 'a
) -> (<FnOnce<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
[src]
ptr: *const FnOnce<Args, Output = Output> + 'a
) -> (<FnOnce<Args, Output = Output> + 'a as DynSized>::Meta, *const ())