[−][src]Struct abi_stable::erased_types::DynTrait
DynTrait implements ffi-safe trait objects,for a selection of traits.
Passing opaque values around with DynTrait<_>
One can pass non-StableAbi types around by using type erasure,using this type.
It generally looks like DynTrait<'borrow,Pointer<()>,Interface>
,where:
-
'borrow
is the borrow that the type that was erased had. -
Pointer
implementsstd::ops::Deref
. -
Interface
is anInterfaceType
,which describes what traits are required when constructing theDynTrait<_>
and which ones it implements.
The InterfaceType
trait allows describing which traits are required
when constructing a DynTrait<_>
,and which ones it implements.
Construction
To construct a DynTrait<_>
one can use these associated functions:
-
from_value
: Can be constructed from the value directly. Requires a value that implements ImplType. -
from_ptr
: Can be constructed from a pointer of a value. Requires a value that implements ImplType. -
from_any_value
: Can be constructed from the value directly.Requires a'static
value. -
from_any_ptr
Can be constructed from a pointer of a value.Requires a'static
value. -
from_borrowing_value
: Can be constructed from the value directly.Cannot unerase the DynTrait afterwards. -
from_borrowing_ptr
Can be constructed from a pointer of a value.Cannot unerase the DynTrait afterwards.
DynTrait uses the impls of the value in methods, which means that the pointer itself does not have to implement those traits,
Trait object
DynTrait<'borrow,Pointer<()>,Interface>
can be used as a trait object for any combination of
the traits listed below.
These are the traits:
-
Send
-
Sync
-
Iterator
-
DoubleEndedIterator
-
std::fmt::Write
-
std::io::Write
-
std::io::Seek
-
std::io::Read
-
std::io::BufRead
-
Clone
-
Display
-
Debug
-
std::error::Error
-
Default: Can be called as an inherent method.
-
Eq
-
PartialEq
-
Ord
-
PartialOrd
-
Hash
-
serde::Deserialize: first deserializes from a string,and then calls the objects' Deserialize impl.
-
serde::Serialize: first calls the objects' Deserialize impl,then serializes that as a string.
Deconstruction
DynTrait<_>
can then be unwrapped into a concrete type,
within the same dynamic library/executable that constructed it,
using these (fallible) conversion methods:
-
into_unerased_impltype: Unwraps into a pointer to
T
. WhereDynTrait<P<()>,Interface>
's Interface must equal<T as ImplType>::Interface
-
as_unerased_impltype: Unwraps into a
&T
. WhereDynTrait<P<()>,Interface>
's Interface must equal<T as ImplType>::Interface
-
as_unerased_mut_impltype: Unwraps into a
&mut T
. WhereDynTrait<P<()>,Interface>
's Interface must equal<T as ImplType>::Interface
-
into_unerased:Unwraps into a pointer to
T
.RequiresT:'static
. -
as_unerased:Unwraps into a
&T
.RequiresT:'static
. -
as_unerased_mut:Unwraps into a
&mut T
.RequiresT:'static
.
DynTrait
cannot be converted back if it was created
using DynTrait::from_borrowing_*
.
Passing DynTrait between dynamic libraries
Passing DynTrait between dynamic libraries (as in between the dynamic libraries directly loaded by the same binary/dynamic library) may cause the program to panic at runtime with an error message stating that the trait is not implemented for the specific interface.
This can only happen if you are passing DynTrait between dynamic libraries, or if DynTrait was instantiated in the parent passed to a child, a DynTrait instantiated in a child dynamic library passed to the parent should not cause a panic,it would be a bug.
binary
_________|___________
lib0 lib1 lib2
| | |
lib00 lib10 lib20
In this diagram passing a DynTrait constructed in lib00 to anything other than the binary or lib0 will cause the panic to happen if:
-
The InterfaceType requires extra traits in the version of the Interface that lib1 and lib2 know about (that the binary does not require).
-
lib1 or lib2 attempt to call methods that require the traits that were added to the InterfaceType,in versions of that interface that only they know about.
serializing/deserializing DynTraits
To be able to serialize and deserialize a DynTrait,
the interface it uses must implement SerializeProxyType
and DeserializeDyn
,
and the implementation type must implement SerializeImplType
.
For a more realistic example you can look at the "examples/0_modules_and_interface_types" crates in the repository for this crate.
use abi_stable::{ StableAbi, impl_get_type_info, sabi_extern_fn, erased_types::{ InterfaceType,DeserializeDyn,SerializeProxyType,ImplType,SerializeImplType, TypeInfo, }, external_types::{RawValueRef,RawValueBox}, prefix_type::{PrefixTypeTrait, WithMetadata}, type_level::bools::*, DynTrait, std_types::{RBox, RStr,RBoxError,RResult,ROk,RErr}, traits::IntoReprC, }; use serde::{Deserialize,Serialize}; /// An `InterfaceType` describing which traits are implemented by FooInterfaceBox. #[repr(C)] #[derive(StableAbi)] #[sabi(impl_InterfaceType(Sync,Debug,Clone,Serialize,Deserialize,PartialEq))] pub struct FooInterface; /// The state passed to most functions in the TextOpsMod module. pub type FooInterfaceBox = DynTrait<'static,RBox<()>,FooInterface>; /// First <ConcreteType as DeserializeImplType>::serialize_impl returns /// a RawValueBox containing the serialized data, /// then the returned RawValueBox is serialized. impl<'s> SerializeProxyType<'s> for FooInterface{ type Proxy=RawValueBox; } impl<'borr> DeserializeDyn<'borr,FooInterfaceBox> for FooInterface { type Proxy = RawValueRef<'borr>; fn deserialize_dyn(s: RawValueRef<'borr>) -> Result<FooInterfaceBox, RBoxError> { MODULE .deserialize_foo()(s.get_rstr()) .into_result() } } // `#[sabi(kind(Prefix))]` declares this type as being a prefix-type, // generating both of these types:<br> // // - Module_Prefix`: A struct with the fields up to (and including) the field with the // `#[sabi(last_prefix_field)]` attribute. // // - Module_Ref`: An ffi-safe pointer to a `Module`,with methods to get `Module`'s fields. #[repr(C)] #[derive(StableAbi)] #[sabi(kind(Prefix))] #[sabi(missing_field(panic))] pub struct Module{ #[sabi(last_prefix_field)] pub deserialize_foo:extern "C" fn(s:RStr<'_>)->RResult<FooInterfaceBox,RBoxError>, } // This is how ffi-safe pointers to non-generic prefix types are constructed // at compile-time. const MODULE: Module_Ref = { const S: &WithMetadata<Module> = &WithMetadata::new( PrefixTypeTrait::METADATA, Module{ deserialize_foo, } ); Module_Ref(S.static_as_prefix()) }; ///////////////////////////////////////////////////////////////////////////////////////// //// In implementation crate (the one that gets compiled as a dynamic library) ///// ///////////////////////////////////////////////////////////////////////////////////////// #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] pub struct Foo{ name:String, } impl ImplType for Foo { type Interface = FooInterface; const INFO: &'static TypeInfo=impl_get_type_info! { Foo }; } impl<'s> SerializeImplType<'s> for Foo { type Interface = FooInterface; fn serialize_impl(&'s self) -> Result<RawValueBox, RBoxError> { match serde_json::to_string(self) { Ok(v)=>{ RawValueBox::try_from_string(v) .map_err(RBoxError::new) } Err(e)=>Err(RBoxError::new(e)), } } } #[sabi_extern_fn] pub fn deserialize_foo(s:RStr<'_>)->RResult<FooInterfaceBox,RBoxError>{ match serde_json::from_str::<Foo>(s.into()) { Ok(x) => ROk(DynTrait::from_value(x)), Err(e) => RErr(RBoxError::new(e)), } } let foo=Foo{name:"nope".into()}; let object=DynTrait::from_value(foo.clone()); assert_eq!( serde_json::from_str::<FooInterfaceBox>(r##" { "name":"nope" } "##).unwrap(), object ); assert_eq!( serde_json::to_string(&object).unwrap(), r##"{"name":"nope"}"## );
Examples
In the Readme
The primary example using DynTrait<_>
is in the readme.
Readme is in the repository for this crate, crates.io, lib.rs.
Comparing DynTraits
This is only possible if the erased types don't contain borrows,
and they are not constructed using DynTrait::from_borrowing_*
methods.
DynTraits wrapping different pointer types can be compared with each other, it simply uses the values' implementation of PartialEq.
use abi_stable::{ DynTrait, erased_types::interfaces::PartialEqInterface, std_types::RArc, }; { let left:DynTrait<'static,&(),PartialEqInterface>= DynTrait::from_any_ptr(&100,PartialEqInterface); let mut n100=100; let right:DynTrait<'static,&mut (),PartialEqInterface>= DynTrait::from_any_ptr(&mut n100,PartialEqInterface); assert_eq!(left,right); } { let left= DynTrait::from_any_value(200,PartialEqInterface); let right= DynTrait::from_any_ptr(RArc::new(200),PartialEqInterface); assert_eq!(left,right); }
Writing to a DynTrait
This is an example of using the write!()
macro with DynTrait.
use abi_stable::{ DynTrait, erased_types::interfaces::FmtWriteInterface, }; use std::fmt::Write; let mut buffer=String::new(); let mut wrapped:DynTrait<'static,&mut (),FmtWriteInterface>= DynTrait::from_any_ptr(&mut buffer,FmtWriteInterface); write!(wrapped,"Foo").unwrap(); write!(wrapped,"Bar").unwrap(); write!(wrapped,"Baz").unwrap(); drop(wrapped); assert_eq!(&buffer[..],"FooBarBaz");
Iteration
Using DynTrait
as an Iterator
and DoubleEndedIterator
.
use abi_stable::{ DynTrait, erased_types::interfaces::DEIteratorInterface, }; let mut wrapped=DynTrait::from_any_value(0..=10,DEIteratorInterface::NEW); assert_eq!( wrapped.by_ref().take(5).collect::<Vec<_>>(), vec![0,1,2,3,4] ); assert_eq!( wrapped.rev().collect::<Vec<_>>(), vec![10,9,8,7,6,5] );
Making pointers compatible with DynTrait
To make pointers compatible with DynTrait,they must imlement the
abi_stable::pointer_trait::{GetPointerKind,Deref,CanTransmuteElement}
traits
as shown in the example.
GetPointerKind
should generally be implemented with type Kind=PK_SmartPointer
.
The exception is in the case that it is a #[repr(transparent)]
wrapper around a &
or a &mut
,
in which case it should implement GetPointerKind<Kind=PK_Reference>
or GetPointerKind<Kind=PK_MutReference>
respectively.
Example
This is an example of a newtype wrapping an RBox<T>
.
use abi_stable::DynTrait; fn main(){ let lines="line0\nline1\nline2"; let mut iter=NewtypeBox::new(lines.lines()); // The type annotation here is just to show the type,it's not necessary. let mut wrapper:DynTrait<'_,NewtypeBox<()>,IteratorInterface>= DynTrait::from_borrowing_ptr(iter,IteratorInterface); // You can clone the DynTrait! let clone=wrapper.clone(); assert_eq!( wrapper.next(), Some("line0") ); assert_eq!( wrapper.next(), Some("line1") ); assert_eq!( wrapper.next(), Some("line2") ); assert_eq!( wrapper.next(), None ); assert_eq!( clone.rev().collect::<Vec<_>>(), vec!["line2","line1","line0"], ) } ///////////////////////////////////////// use std::ops::{Deref, DerefMut}; use abi_stable::{ StableAbi, InterfaceType, std_types::RBox, erased_types::IteratorItem, pointer_trait::{ PK_SmartPointer,GetPointerKind,CanTransmuteElement }, type_level::bools::True, }; #[repr(transparent)] #[derive(Default,Clone,StableAbi)] pub struct NewtypeBox<T>{ box_:RBox<T>, } impl<T> NewtypeBox<T>{ pub fn new(value:T)->Self{ Self{ box_:RBox::new(value) } } } impl<T> Deref for NewtypeBox<T>{ type Target=T; fn deref(&self)->&T{ &*self.box_ } } impl<T> DerefMut for NewtypeBox<T>{ fn deref_mut(&mut self)->&mut T{ &mut *self.box_ } } unsafe impl<T> GetPointerKind for NewtypeBox<T>{ type Kind=PK_SmartPointer; } unsafe impl<T,O> CanTransmuteElement<O> for NewtypeBox<T> where // Using this to ensure that the pointer is safe to wrap, // while this is not necessary for `RBox<T>`, // it might be for some other pointer type. RBox<T>:CanTransmuteElement<O,Kind=Self::Kind> { type TransmutedPtr = NewtypeBox<O>; } ///////////////////////////////////////// #[repr(C)] #[derive(StableAbi)] #[sabi(impl_InterfaceType(Sync,Send,Iterator,DoubleEndedIterator,Clone,Debug))] pub struct IteratorInterface; impl<'a> IteratorItem<'a> for IteratorInterface{ type Item=&'a str; }
Implementations
impl DynTrait<'static, &'static (), ()>
[src]
pub fn from_value<T>(object: T) -> DynTrait<'static, RBox<()>, T::Interface>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
T: ImplType,
T::Interface: InterfaceBound,
T: GetVtable<'static, T, RBox<()>, RBox<T>, <T as ImplType>::Interface>,
[src]
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
T: ImplType,
T::Interface: InterfaceBound,
T: GetVtable<'static, T, RBox<()>, RBox<T>, <T as ImplType>::Interface>,
Constructs the DynTrait<_>
from a T:ImplType
.
Use this whenever possible instead of from_any_value
,
because it produces better error messages when unerasing the DynTrait<_>
pub fn from_ptr<P, T>(
object: P
) -> DynTrait<'static, P::TransmutedPtr, T::Interface>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
T: ImplType,
T::Interface: InterfaceBound,
T: GetVtable<'static, T, P::TransmutedPtr, P, <T as ImplType>::Interface>,
P: Deref<Target = T> + CanTransmuteElement<()> + GetPointerKind,
P::TransmutedPtr: GetPointerKind,
[src]
object: P
) -> DynTrait<'static, P::TransmutedPtr, T::Interface>ⓘ
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
T: ImplType,
T::Interface: InterfaceBound,
T: GetVtable<'static, T, P::TransmutedPtr, P, <T as ImplType>::Interface>,
P: Deref<Target = T> + CanTransmuteElement<()> + GetPointerKind,
P::TransmutedPtr: GetPointerKind,
Constructs the DynTrait<_>
from a pointer to a T:ImplType
.
Use this whenever possible instead of from_any_ptr
,
because it produces better error messages when unerasing the DynTrait<_>
pub fn from_any_value<T, I>(
object: T,
interface: I
) -> DynTrait<'static, RBox<()>, I>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
T: 'static,
I: InterfaceBound,
InterfaceFor<T, I, TU_Unerasable>: GetVtable<'static, T, RBox<()>, RBox<T>, I>,
[src]
object: T,
interface: I
) -> DynTrait<'static, RBox<()>, I>ⓘ
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
T: 'static,
I: InterfaceBound,
InterfaceFor<T, I, TU_Unerasable>: GetVtable<'static, T, RBox<()>, RBox<T>, I>,
Constructs the DynTrait<_>
from a type that doesn't borrow anything.
pub fn from_any_ptr<P, T, I>(
object: P,
_interface: I
) -> DynTrait<'static, P::TransmutedPtr, I>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
I: InterfaceBound,
T: 'static,
InterfaceFor<T, I, TU_Unerasable>: GetVtable<'static, T, P::TransmutedPtr, P, I>,
P: Deref<Target = T> + CanTransmuteElement<()> + GetPointerKind,
P::TransmutedPtr: GetPointerKind,
[src]
object: P,
_interface: I
) -> DynTrait<'static, P::TransmutedPtr, I>ⓘ
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
I: InterfaceBound,
T: 'static,
InterfaceFor<T, I, TU_Unerasable>: GetVtable<'static, T, P::TransmutedPtr, P, I>,
P: Deref<Target = T> + CanTransmuteElement<()> + GetPointerKind,
P::TransmutedPtr: GetPointerKind,
Constructs the DynTrait<_>
from a pointer to a
type that doesn't borrow anything.
pub fn from_borrowing_value<'borr, T, I>(
object: T,
interface: I
) -> DynTrait<'borr, RBox<()>, I>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
T: 'borr,
I: InterfaceBound,
InterfaceFor<T, I, TU_Opaque>: GetVtable<'borr, T, RBox<()>, RBox<T>, I>,
[src]
object: T,
interface: I
) -> DynTrait<'borr, RBox<()>, I>ⓘ
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
T: 'borr,
I: InterfaceBound,
InterfaceFor<T, I, TU_Opaque>: GetVtable<'borr, T, RBox<()>, RBox<T>, I>,
Constructs the DynTrait<_>
from a value with a 'borr
borrow.
Cannot unerase the DynTrait afterwards.
pub fn from_borrowing_ptr<'borr, P, T, I>(
object: P,
_interface: I
) -> DynTrait<'borr, P::TransmutedPtr, I>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
T: 'borr,
I: InterfaceBound,
InterfaceFor<T, I, TU_Opaque>: GetVtable<'borr, T, P::TransmutedPtr, P, I>,
P: Deref<Target = T> + CanTransmuteElement<()> + GetPointerKind,
P::TransmutedPtr: GetPointerKind,
[src]
object: P,
_interface: I
) -> DynTrait<'borr, P::TransmutedPtr, I>ⓘ
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
T: 'borr,
I: InterfaceBound,
InterfaceFor<T, I, TU_Opaque>: GetVtable<'borr, T, P::TransmutedPtr, P, I>,
P: Deref<Target = T> + CanTransmuteElement<()> + GetPointerKind,
P::TransmutedPtr: GetPointerKind,
Constructs the DynTrait<_>
from a pointer to the erased type
with a 'borr
borrow.
Cannot unerase the DynTrait afterwards.
impl<'borr, P, I, EV> DynTrait<'borr, P, I, EV> where
P: GetPointerKind<Target = ()>,
[src]
P: GetPointerKind<Target = ()>,
pub fn with_extra_value<OrigPtr, Unerasability>(
ptr: OrigPtr,
extra_value: EV
) -> DynTrait<'borr, P, I, EV>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
OrigPtr::Target: Sized + 'borr,
I: InterfaceBound,
InterfaceFor<OrigPtr::Target, I, Unerasability>: GetVtable<'borr, OrigPtr::Target, P, OrigPtr, I>,
OrigPtr: CanTransmuteElement<(), TransmutedPtr = P>,
[src]
ptr: OrigPtr,
extra_value: EV
) -> DynTrait<'borr, P, I, EV>ⓘ
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
OrigPtr::Target: Sized + 'borr,
I: InterfaceBound,
InterfaceFor<OrigPtr::Target, I, Unerasability>: GetVtable<'borr, OrigPtr::Target, P, OrigPtr, I>,
OrigPtr: CanTransmuteElement<(), TransmutedPtr = P>,
Constructs an DynTrait from an erased pointer and an extra value.
impl<'borr, 'a, I, EV> DynTrait<'borr, RRef<'a, ()>, I, EV>
[src]
pub const fn from_const<T, Unerasability>(
ptr: &'a T,
unerasability: Unerasability,
vtable_for: VTableDT<'borr, T, RRef<'a, ()>, RRef<'a, T>, I, Unerasability>,
extra_value: EV
) -> Self where
T: 'borr,
[src]
ptr: &'a T,
unerasability: Unerasability,
vtable_for: VTableDT<'borr, T, RRef<'a, ()>, RRef<'a, T>, I, Unerasability>,
extra_value: EV
) -> Self where
T: 'borr,
This function allows constructing a DynTrait in a constant/static.
Parameters
ptr
:
This is generally constructed with RRef::new(&value)
RRef
is a reference-like type that can be erased inside a const fn
on stable Rust
(once it becomes possible to unsafely cast &T
to &()
inside a const fn
,
and the minimum Rust version is bumped,this type will be replaced with a reference)
unerasability
can be either:
-
TU_Unerasable
: Which allows the trait object to be unerased,requires that the value implements any. -
TU_Opaque
: Which does not allow the trait object to be unerased.
vtable_for
:
This is constructible with VTableDT::GET
.
VTableDT
wraps the vtable for a DynTrait
,
while keeping the original type and pointer type that it was constructed for,
allowing this function to be safe to call.
extra_value
:
This is used by #[sabi_trait]
trait objects to store their vtable inside DynTrait.
Example
use abi_stable::{ erased_types::{ interfaces::DebugDisplayInterface, DynTrait,TU_Opaque,VTableDT, }, sabi_types::RRef, }; static STRING:&str="What the heck"; static DYN:DynTrait<'static,RRef<'static,()>,DebugDisplayInterface,()>= DynTrait::from_const( &STRING, TU_Opaque, VTableDT::GET, (), ); fn main(){ assert_eq!( format!("{}",DYN), format!("{}",STRING) ); assert_eq!( format!("{:?}",DYN), format!("{:?}",STRING) ); }
impl<P, I, EV> DynTrait<'static, P, I, EV> where
P: GetPointerKind,
[src]
P: GetPointerKind,
pub fn sabi_is_same_type<Other, I2, EV2>(
&self,
other: &DynTrait<'static, Other, I2, EV2>
) -> bool where
I2: InterfaceBound,
Other: GetPointerKind,
[src]
&self,
other: &DynTrait<'static, Other, I2, EV2>
) -> bool where
I2: InterfaceBound,
Other: GetPointerKind,
Allows checking whether 2 DynTrait<_>
s have a value of the same type.
Notes:
-
Types from different dynamic libraries/executables are never considered equal.
-
DynTrait
s constructed usingDynTrait::from_borrowing_*
are never considered to wrap the same type.
impl<'borr, P, I, EV> DynTrait<'borr, P, I, PrefixRef<EV>> where
P: GetPointerKind,
[src]
P: GetPointerKind,
pub fn sabi_et_vtable(&self) -> PrefixRef<EV>
[src]
A vtable used by #[sabi_trait]
derived trait objects.
impl<'borr, P, I, EV> DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
[src]
P: GetPointerKind,
pub fn sabi_extra_value(&self) -> &EV
[src]
Gets access to the extra value that was stored in this DynTrait in the
with_extra_value
constructor.
pub fn sabi_object_address(&self) -> usize where
P: Deref,
[src]
P: Deref,
Returns the address of the wrapped object.
pub fn sabi_erased_ref(&self) -> &ErasedObject where
P: Deref,
[src]
P: Deref,
Gets a reference pointing to the erased object.
pub fn sabi_erased_mut(&mut self) -> &mut ErasedObject where
P: DerefMut,
[src]
P: DerefMut,
Gets a mutable reference pointing to the erased object.
pub fn sabi_as_rref(&self) -> RRef<'_, ()> where
P: Deref,
[src]
P: Deref,
Gets an RRef
pointing to the erased object.
pub fn sabi_as_rmut(&mut self) -> RMut<'_, ()> where
P: DerefMut,
[src]
P: DerefMut,
Gets an RMut
pointing to the erased object.
pub fn sabi_with_value<F, R>(self, f: F) -> R where
P: OwnedPointer<Target = ()>,
F: FnOnce(MovePtr<'_, ()>) -> R,
[src]
P: OwnedPointer<Target = ()>,
F: FnOnce(MovePtr<'_, ()>) -> R,
Calls the f
callback with an MovePtr
pointing to the erased object.
impl<'borr, P, I, EV> DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
[src]
P: GetPointerKind,
pub fn into_unerased_impltype<T>(
self
) -> Result<P::TransmutedPtr, UneraseError<Self>> where
P: CanTransmuteElement<T>,
P::Target: Sized,
T: ImplType,
[src]
self
) -> Result<P::TransmutedPtr, UneraseError<Self>> where
P: CanTransmuteElement<T>,
P::Target: Sized,
T: ImplType,
Unwraps the DynTrait<_>
into a pointer of
the concrete type that it was constructed with.
T is required to implement ImplType.
Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this
DynTrait<_>
was constructed. -
The DynTrait was constructed using a
from_borrowing_*
method -
T
is not the concrete type thisDynTrait<_>
was constructed with.
pub fn as_unerased_impltype<T>(&self) -> Result<&T, UneraseError<&Self>> where
P: Deref + CanTransmuteElement<T>,
T: ImplType,
[src]
P: Deref + CanTransmuteElement<T>,
T: ImplType,
Unwraps the DynTrait<_>
into a reference of
the concrete type that it was constructed with.
T is required to implement ImplType.
Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this
DynTrait<_>
was constructed. -
The DynTrait was constructed using a
from_borrowing_*
method -
T
is not the concrete type thisDynTrait<_>
was constructed with.
pub fn as_unerased_mut_impltype<T>(
&mut self
) -> Result<&mut T, UneraseError<&mut Self>> where
P: DerefMut + CanTransmuteElement<T>,
T: ImplType,
[src]
&mut self
) -> Result<&mut T, UneraseError<&mut Self>> where
P: DerefMut + CanTransmuteElement<T>,
T: ImplType,
Unwraps the DynTrait<_>
into a mutable reference of
the concrete type that it was constructed with.
T is required to implement ImplType.
Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this
DynTrait<_>
was constructed. -
The DynTrait was constructed using a
from_borrowing_*
method -
T
is not the concrete type thisDynTrait<_>
was constructed with.
pub fn into_unerased<T>(self) -> Result<P::TransmutedPtr, UneraseError<Self>> where
T: 'static,
P: CanTransmuteElement<T>,
P::Target: Sized,
Self: DynTraitBound<'borr>,
InterfaceFor<T, I, TU_Unerasable>: ImplType,
[src]
T: 'static,
P: CanTransmuteElement<T>,
P::Target: Sized,
Self: DynTraitBound<'borr>,
InterfaceFor<T, I, TU_Unerasable>: ImplType,
Unwraps the DynTrait<_>
into a pointer of
the concrete type that it was constructed with.
T is required to not borrow anything.
Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this
DynTrait<_>
was constructed. -
The DynTrait was constructed using a
from_borrowing_*
method -
T
is not the concrete type thisDynTrait<_>
was constructed with.
pub fn as_unerased<T>(&self) -> Result<&T, UneraseError<&Self>> where
T: 'static,
P: Deref + CanTransmuteElement<T>,
Self: DynTraitBound<'borr>,
InterfaceFor<T, I, TU_Unerasable>: ImplType,
[src]
T: 'static,
P: Deref + CanTransmuteElement<T>,
Self: DynTraitBound<'borr>,
InterfaceFor<T, I, TU_Unerasable>: ImplType,
Unwraps the DynTrait<_>
into a reference of
the concrete type that it was constructed with.
T is required to not borrow anything.
Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this
DynTrait<_>
was constructed. -
The DynTrait was constructed using a
from_borrowing_*
method -
T
is not the concrete type thisDynTrait<_>
was constructed with.
pub fn as_unerased_mut<T>(&mut self) -> Result<&mut T, UneraseError<&mut Self>> where
P: DerefMut + CanTransmuteElement<T>,
Self: DynTraitBound<'borr>,
InterfaceFor<T, I, TU_Unerasable>: ImplType,
[src]
P: DerefMut + CanTransmuteElement<T>,
Self: DynTraitBound<'borr>,
InterfaceFor<T, I, TU_Unerasable>: ImplType,
Unwraps the DynTrait<_>
into a mutable reference of
the concrete type that it was constructed with.
T is required to not borrow anything.
Errors
This will return an error in any of these conditions:
-
It is called in a dynamic library/binary outside the one from which this
DynTrait<_>
was constructed. -
The DynTrait was constructed using a
from_borrowing_*
method -
T
is not the concrete type thisDynTrait<_>
was constructed with.
pub unsafe fn unchecked_into_unerased<T>(self) -> P::TransmutedPtr where
P: Deref + CanTransmuteElement<T>,
P::Target: Sized,
[src]
P: Deref + CanTransmuteElement<T>,
P::Target: Sized,
Unwraps the DynTrait<_>
into a pointer to T,
without checking whether T
is the type that the DynTrait was constructed with.
Safety
You must check that T
is the type that DynTrait was constructed
with through other means.
pub unsafe fn unchecked_as_unerased<T>(&self) -> &T where
P: Deref,
[src]
P: Deref,
Unwraps the DynTrait<_>
into a reference to T,
without checking whether T
is the type that the DynTrait was constructed with.
Safety
You must check that T
is the type that DynTrait was constructed
with through other means.
pub unsafe fn unchecked_as_unerased_mut<T>(&mut self) -> &mut T where
P: DerefMut,
[src]
P: DerefMut,
Unwraps the DynTrait<_>
into a mutable reference to T,
without checking whether T
is the type that the DynTrait was constructed with.
Safety
You must check that T
is the type that DynTrait was constructed
with through other means.
impl<'borr, P, I, EV> DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
I: InterfaceType,
[src]
P: GetPointerKind,
I: InterfaceType,
pub fn reborrow<'re>(&'re self) -> DynTrait<'borr, &'re (), I, EV>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
P: Deref<Target = ()>,
PrivStruct: ReborrowBounds<I::Send, I::Sync>,
EV: Copy,
[src]
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
P: Deref<Target = ()>,
PrivStruct: ReborrowBounds<I::Send, I::Sync>,
EV: Copy,
Creates a shared reborrow of this DynTrait.
The reborrowed DynTrait cannot use these methods:
- DynTrait::default
This is only callable if RObject
is either Send + Sync
or !Send + !Sync
.
pub fn reborrow_mut<'re>(&'re mut self) -> DynTrait<'borr, &'re mut (), I, EV>ⓘNotable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
where
P: DerefMut<Target = ()>,
PrivStruct: ReborrowBounds<I::Send, I::Sync>,
EV: Copy,
[src]
Notable traits for DynTrait<'borr, P, I, EV>
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr, type Item = Item;impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>, impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
P: DerefMut<Target = ()>,
PrivStruct: ReborrowBounds<I::Send, I::Sync>,
EV: Copy,
Creates a mutable reborrow of this DynTrait.
The reborrowed DynTrait cannot use these methods:
-
DynTrait::default
-
DynTrait::clone
This is only callable if RObject
is either Send + Sync
or !Send + !Sync
.
impl<'borr, P, I, EV> DynTrait<'borr, P, I, EV> where
I: InterfaceBound + 'borr,
EV: 'borr,
P: GetPointerKind,
[src]
I: InterfaceBound + 'borr,
EV: 'borr,
P: GetPointerKind,
pub fn default(&self) -> Self where
P: Deref + GetPointerKind<Kind = PK_SmartPointer>,
I: InterfaceType<Default = Implemented<Default>>,
EV: Copy,
[src]
P: Deref + GetPointerKind<Kind = PK_SmartPointer>,
I: InterfaceType<Default = Implemented<Default>>,
EV: Copy,
Constructs a DynTrait<P,I>
with the default value for P
.
Reborrowing
This cannot be called with a reborrowed DynTrait:
let object=DynTrait::from_any_value((),DefaultInterface); let borrow=object.reborrow(); let _=borrow.default();
let object=DynTrait::from_any_value((),DefaultInterface); let borrow=object.reborrow_mut(); let _=borrow.default();
pub fn serialize_into_proxy<'a>(&'a self) -> Result<I::ProxyType, RBoxError> where
P: Deref,
I: InterfaceType<Serialize = Implemented<Serialize>>,
I: GetSerializeProxyType<'a>,
[src]
P: Deref,
I: InterfaceType<Serialize = Implemented<Serialize>>,
I: GetSerializeProxyType<'a>,
It serializes a DynTrait<_>
into a string by using
<ConcreteType as SerializeImplType>::serialize_impl
.
pub fn deserialize_from_proxy<'de>(proxy: I::Proxy) -> Result<Self, RBoxError> where
P: 'borr + Deref,
I: DeserializeDyn<'de, Self>,
[src]
P: 'borr + Deref,
I: DeserializeDyn<'de, Self>,
Deserializes a DynTrait<'borr,_>
from a proxy type,by using
<I as DeserializeDyn<'borr,Self>>::deserialize_dyn
.
impl<'borr, P, I, Item, EV> DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr,
[src]
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr,
pub fn skip_eager(&mut self, n: usize)
[src]
Eagerly skips n elements from the iterator.
This method is faster than using Iterator::skip
.
Example
let mut iter=0..20; let mut wrapped=DynTrait::from_any_ptr(&mut iter,IteratorInterface::NEW); assert_eq!(wrapped.next(),Some(0)); wrapped.skip_eager(2); assert_eq!(wrapped.next(),Some(3)); assert_eq!(wrapped.next(),Some(4)); assert_eq!(wrapped.next(),Some(5)); wrapped.skip_eager(2); assert_eq!(wrapped.next(),Some(8)); assert_eq!(wrapped.next(),Some(9)); wrapped.skip_eager(9); assert_eq!(wrapped.next(),Some(19)); assert_eq!(wrapped.next(),None );
pub fn extending_rvec(
&mut self,
buffer: &mut RVec<Item>,
taking: ROption<usize>
)
[src]
&mut self,
buffer: &mut RVec<Item>,
taking: ROption<usize>
)
Extends the RVec<Item>
with the self
Iterator.
Extends buffer
with as many elements of the iterator as taking
specifies:
-
RNone: Yields all elements.Use this with care,since Iterators can be infinite.
-
RSome(n): Yields n elements.
Example
let mut wrapped=DynTrait::from_any_value(0.. ,IteratorInterface::NEW); let mut buffer=vec![ 101,102,103 ].into_c(); wrapped.extending_rvec(&mut buffer,RSome(5)); assert_eq!( &buffer[..], &*vec![101,102,103,0,1,2,3,4] ); assert_eq!( wrapped.next(),Some(5)); assert_eq!( wrapped.next(),Some(6)); assert_eq!( wrapped.next(),Some(7));
impl<'borr, P, I, Item, EV> DynTrait<'borr, P, I, EV> where
Self: Iterator<Item = Item>,
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<DoubleEndedIterator = Implemented<DoubleEndedIterator>>,
Item: 'borr,
[src]
Self: Iterator<Item = Item>,
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<DoubleEndedIterator = Implemented<DoubleEndedIterator>>,
Item: 'borr,
pub fn nth_back_(&mut self, nth: usize) -> Option<Item>
[src]
pub fn extending_rvec_back(
&mut self,
buffer: &mut RVec<Item>,
taking: ROption<usize>
)
[src]
&mut self,
buffer: &mut RVec<Item>,
taking: ROption<usize>
)
Extends the RVec<Item>
with the back of the self
DoubleEndedIterator.
Extends buffer
with as many elements of the iterator as taking
specifies:
-
RNone: Yields all elements.Use this with care,since Iterators can be infinite.
-
RSome(n): Yields n elements.
Example
let mut wrapped=DynTrait::from_any_value(0..=3 ,DEIteratorInterface::NEW); let mut buffer=vec![ 101,102,103 ].into_c(); wrapped.extending_rvec_back(&mut buffer,RNone); assert_eq!( &buffer[..], &*vec![101,102,103,3,2,1,0] )
Trait Implementations
impl<'borr, P, I, EV> BufRead for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>, IoBufRead = Implemented<IoBufRead>>,
[src]
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>, IoBufRead = Implemented<IoBufRead>>,
pub fn fill_buf(&mut self) -> Result<&[u8]>
[src]
pub fn consume(&mut self, amount: usize)
[src]
pub fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
1.0.0[src]
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
pub fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn split(self, byte: u8) -> Split<Self>
1.0.0[src]
pub fn lines(self) -> Lines<Self>
1.0.0[src]
impl<'borr, P, I, EV> Clone for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound,
Self: CloneImpl<<P as GetPointerKind>::Kind>,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound,
Self: CloneImpl<<P as GetPointerKind>::Kind>,
Clone is implemented for references and smart pointers,
using GetPointerKind
to decide whether P
is a smart pointer or a reference.
DynTrait does not implement Clone if P==&mut ()
:
let mut object=DynTrait::from_any_value((),()); let borrow=object.reborrow_mut(); let _=borrow.clone();
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'borr, P, I, EV> Debug for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound<Debug = Implemented<Debug>>,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound<Debug = Implemented<Debug>>,
impl<'de, 'borr: 'de, P, I, EV> Deserialize<'de> for DynTrait<'borr, P, I, EV> where
EV: 'borr,
P: Deref + GetPointerKind + 'borr,
I: InterfaceBound + 'borr,
I: DeserializeDyn<'de, Self>,
<I as DeserializeDyn<'de, Self>>::Proxy: Deserialize<'de>,
[src]
EV: 'borr,
P: Deref + GetPointerKind + 'borr,
I: InterfaceBound + 'borr,
I: DeserializeDyn<'de, Self>,
<I as DeserializeDyn<'de, Self>>::Proxy: Deserialize<'de>,
First it Deserializes a string,then it deserializes into a
DynTrait<_>
,by using <I as DeserializeOwnedInterface>::deserialize_impl
.
pub fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<'borr, P, I, EV> Display for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound<Display = Implemented<Display>>,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound<Display = Implemented<Display>>,
impl<'borr, P, I, Item, EV> DoubleEndedIterator for DynTrait<'borr, P, I, EV> where
Self: Iterator<Item = Item>,
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<DoubleEndedIterator = Implemented<DoubleEndedIterator>>,
Item: 'borr,
[src]
Self: Iterator<Item = Item>,
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<DoubleEndedIterator = Implemented<DoubleEndedIterator>>,
Item: 'borr,
pub fn next_back(&mut self) -> Option<Item>
[src]
pub fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]
pub fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]
pub fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
pub fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]
F: FnMut(B, Self::Item) -> B,
pub fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]
P: FnMut(&Self::Item) -> bool,
impl<'borr, P, I, EV> Drop for DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
[src]
P: GetPointerKind,
impl<'borr, P, I, EV> DynTraitBound<'borr> for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound,
type Interface = I
impl<P, I, EV> Eq for DynTrait<'static, P, I, EV> where
Self: PartialEq,
P: Deref + GetPointerKind,
I: InterfaceBound<Eq = Implemented<Eq>>,
[src]
Self: PartialEq,
P: Deref + GetPointerKind,
I: InterfaceBound<Eq = Implemented<Eq>>,
impl<'borr, P, I, EV> Error for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound<Display = Implemented<Display>, Debug = Implemented<Debug>, Error = Implemented<Error>>,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound<Display = Implemented<Display>, Debug = Implemented<Debug>, Error = Implemented<Error>>,
pub fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
pub fn backtrace(&self) -> Option<&Backtrace>
[src]
pub fn description(&self) -> &str
1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<'borr, P, I, EV> GetStaticEquivalent_ for DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable_Ref<'borr, P, I>: StableAbi,
[src]
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable_Ref<'borr, P, I>: StableAbi,
type StaticEquivalent = _static_DynTrait<'static, __GetStaticEquivalent<P>, __GetStaticEquivalent<I>, __GetStaticEquivalent<EV>>
impl<'borr, P, I, EV> Hash for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound<Hash = Implemented<Hash>>,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound<Hash = Implemented<Hash>>,
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'borr, P, I, Item, EV> Iterator for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr,
[src]
P: DerefMut + GetPointerKind,
I: IteratorItemOrDefault<'borr, Item = Item>,
I: InterfaceBound<Iterator = Implemented<Iterator>>,
Item: 'borr,
type Item = Item
The type of the elements being iterated over.
pub fn next(&mut self) -> Option<Item>
[src]
pub fn nth(&mut self, nth: usize) -> Option<Item>
[src]
pub fn size_hint(&self) -> (usize, Option<usize>)
[src]
pub fn count(mut self: Self) -> usize
[src]
pub fn last(mut self: Self) -> Option<Item>
[src]
pub fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]
pub fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]
pub fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]
U: IntoIterator<Item = Self::Item>,
pub fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]
U: IntoIterator,
pub fn intersperse(self, separator: Self::Item) -> Intersperse<Self> where
Self::Item: Clone,
[src]
Self::Item: Clone,
pub fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]
F: FnMut(Self::Item) -> B,
pub fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]
F: FnMut(Self::Item),
pub fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
P: FnMut(&Self::Item) -> bool,
pub fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]
F: FnMut(Self::Item) -> Option<B>,
pub fn enumerate(self) -> Enumerate<Self>
1.0.0[src]
pub fn peekable(self) -> Peekable<Self>
1.0.0[src]
pub fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
P: FnMut(&Self::Item) -> bool,
pub fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
P: FnMut(&Self::Item) -> bool,
pub fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]
P: FnMut(Self::Item) -> Option<B>,
pub fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]
pub fn take(self, n: usize) -> Take<Self>
1.0.0[src]
pub fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]
F: FnMut(&mut St, Self::Item) -> Option<B>,
pub fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
U: IntoIterator,
F: FnMut(Self::Item) -> U,
1.0.0[src]
U: IntoIterator,
F: FnMut(Self::Item) -> U,
pub fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]
Self::Item: IntoIterator,
pub fn fuse(self) -> Fuse<Self>
1.0.0[src]
pub fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]
F: FnMut(&Self::Item),
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
#[must_use =
"if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]pub fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]
B: FromIterator<Self::Item>,
pub fn partition<B, F>(self, f: F) -> (B, B) where
F: FnMut(&Self::Item) -> bool,
B: Default + Extend<Self::Item>,
1.0.0[src]
F: FnMut(&Self::Item) -> bool,
B: Default + Extend<Self::Item>,
pub fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
P: FnMut(&T) -> bool,
[src]
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
P: FnMut(&T) -> bool,
pub fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]
P: FnMut(Self::Item) -> bool,
pub fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
pub fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
pub fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]
F: FnMut(B, Self::Item) -> B,
pub fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]
F: FnMut(Self::Item, Self::Item) -> Self::Item,
pub fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
F: FnMut(Self::Item) -> bool,
pub fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
F: FnMut(Self::Item) -> bool,
pub fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
P: FnMut(&Self::Item) -> bool,
pub fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]
F: FnMut(Self::Item) -> Option<B>,
pub fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
pub fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]
P: FnMut(Self::Item) -> bool,
pub fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
Self: ExactSizeIterator + DoubleEndedIterator,
P: FnMut(Self::Item) -> bool,
1.0.0[src]
Self: ExactSizeIterator + DoubleEndedIterator,
P: FnMut(Self::Item) -> bool,
pub fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
Self::Item: Ord,
pub fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
Self::Item: Ord,
pub fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
F: FnMut(&Self::Item) -> B,
B: Ord,
1.6.0[src]
F: FnMut(&Self::Item) -> B,
B: Ord,
pub fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
pub fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
F: FnMut(&Self::Item) -> B,
B: Ord,
1.6.0[src]
F: FnMut(&Self::Item) -> B,
B: Ord,
pub fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
pub fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]
Self: DoubleEndedIterator,
pub fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
Self: Iterator<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
1.0.0[src]
Self: Iterator<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
pub fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
pub fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
pub fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]
Self: Clone,
pub fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]
S: Sum<Self::Item>,
pub fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]
P: Product<Self::Item>,
pub fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
pub fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
[src]
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
pub fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
pub fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
[src]
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
pub fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
pub fn eq_by<I, F>(self, other: I, eq: F) -> bool where
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
[src]
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
pub fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
pub fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
pub fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
pub fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
pub fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
pub fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]
Self::Item: PartialOrd<Self::Item>,
pub fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
pub fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
impl<P, I, EV> Ord for DynTrait<'static, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound<Ord = Implemented<Ord>>,
Self: PartialOrd + Eq,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound<Ord = Implemented<Ord>>,
Self: PartialOrd + Eq,
pub fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<P, P2, I, EV, EV2> PartialEq<DynTrait<'static, P2, I, EV2>> for DynTrait<'static, P, I, EV> where
P: Deref + GetPointerKind,
P2: Deref + GetPointerKind,
I: InterfaceBound<PartialEq = Implemented<PartialEq>>,
[src]
P: Deref + GetPointerKind,
P2: Deref + GetPointerKind,
I: InterfaceBound<PartialEq = Implemented<PartialEq>>,
pub fn eq(&self, other: &DynTrait<'static, P2, I, EV2>) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<P, P2, I, EV, EV2> PartialOrd<DynTrait<'static, P2, I, EV2>> for DynTrait<'static, P, I, EV> where
P: Deref + GetPointerKind,
P2: Deref + GetPointerKind,
I: InterfaceBound<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<DynTrait<'static, P2, I, EV2>>,
[src]
P: Deref + GetPointerKind,
P2: Deref + GetPointerKind,
I: InterfaceBound<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<DynTrait<'static, P2, I, EV2>>,
pub fn partial_cmp(
&self,
other: &DynTrait<'static, P2, I, EV2>
) -> Option<Ordering>
[src]
&self,
other: &DynTrait<'static, P2, I, EV2>
) -> Option<Ordering>
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'borr, P, I, EV> Read for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>,
[src]
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoRead = Implemented<IoRead>>,
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
[src]
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl<'borr, P, I, EV> Seek for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoSeek = Implemented<IoSeek>>,
[src]
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoSeek = Implemented<IoSeek>>,
pub fn seek(&mut self, pos: SeekFrom) -> Result<u64>
[src]
pub fn stream_len(&mut self) -> Result<u64, Error>
[src]
pub fn stream_position(&mut self) -> Result<u64, Error>
[src]
impl<'borr, P, I, EV> Send for DynTrait<'borr, P, I, EV> where
P: Send + GetPointerKind,
I: InterfaceBound<Send = Implemented<Send>>,
[src]
P: Send + GetPointerKind,
I: InterfaceBound<Send = Implemented<Send>>,
impl<'borr, P, I, EV> Serialize for DynTrait<'borr, P, I, EV> where
P: Deref + GetPointerKind,
I: InterfaceBound<Serialize = Implemented<Serialize>>,
I: GetSerializeProxyType<'borr>,
I::ProxyType: Serialize,
[src]
P: Deref + GetPointerKind,
I: InterfaceBound<Serialize = Implemented<Serialize>>,
I: GetSerializeProxyType<'borr>,
I::ProxyType: Serialize,
First it serializes a DynTrait<_>
into a string by using
impl<'borr, P, I, EV> StableAbi for DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable_Ref<'borr, P, I>: StableAbi,
[src]
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable_Ref<'borr, P, I>: StableAbi,
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
pub const LAYOUT: &'static TypeLayout
[src]
pub const ABI_CONSTS: AbiConsts
[src]
impl<'borr, P, I, EV> Sync for DynTrait<'borr, P, I, EV> where
P: Sync + GetPointerKind,
I: InterfaceBound<Sync = Implemented<Sync>>,
[src]
P: Sync + GetPointerKind,
I: InterfaceBound<Sync = Implemented<Sync>>,
impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<FmtWrite = Implemented<FmtWrite>>,
[src]
P: DerefMut + GetPointerKind,
I: InterfaceBound<FmtWrite = Implemented<FmtWrite>>,
pub fn write_str(&mut self, s: &str) -> Result<(), Error>
[src]
pub fn write_char(&mut self, c: char) -> Result<(), Error>
1.1.0[src]
pub fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
impl<'borr, P, I, EV> Write for DynTrait<'borr, P, I, EV> where
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
[src]
P: DerefMut + GetPointerKind,
I: InterfaceBound<IoWrite = Implemented<IoWrite>>,
pub fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
pub fn flush(&mut self) -> Result<()>
[src]
pub fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<'borr, P, I, EV = ()> !RefUnwindSafe for DynTrait<'borr, P, I, EV>
[src]
impl<'borr, P, I, EV> Unpin for DynTrait<'borr, P, I, EV> where
EV: Unpin,
P: Unpin,
[src]
EV: Unpin,
P: Unpin,
impl<'borr, P, I, EV> UnwindSafe for DynTrait<'borr, P, I, EV> where
EV: UnwindSafe,
P: UnwindSafe,
[src]
EV: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> BorrowOwned<'a> for T where
T: 'a + Clone,
[src]
T: 'a + Clone,
type ROwned = T
The owned type, stored in RCow::Owned
type RBorrowed = &'a T
The borrowed type, stored in RCow::Borrowed
pub fn r_borrow(
&'a <T as BorrowOwned<'a>>::ROwned
) -> <T as BorrowOwned<'a>>::RBorrowed
[src]
&'a <T as BorrowOwned<'a>>::ROwned
) -> <T as BorrowOwned<'a>>::RBorrowed
pub fn r_to_owned(
<T as BorrowOwned<'a>>::RBorrowed
) -> <T as BorrowOwned<'a>>::ROwned
[src]
<T as BorrowOwned<'a>>::RBorrowed
) -> <T as BorrowOwned<'a>>::ROwned
pub fn deref_borrowed(&<T as BorrowOwned<'a>>::RBorrowed) -> &T
[src]
pub fn deref_owned(&<T as BorrowOwned<'a>>::ROwned) -> &T
[src]
pub fn from_cow_borrow(&'a T) -> <T as BorrowOwned<'a>>::RBorrowed
[src]
pub fn from_cow_owned(<T as ToOwned>::Owned) -> <T as BorrowOwned<'a>>::ROwned
[src]
pub fn into_cow_borrow(<T as BorrowOwned<'a>>::RBorrowed) -> &'a T
[src]
pub fn into_cow_owned(<T as BorrowOwned<'a>>::ROwned) -> <T as ToOwned>::Owned
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> GetWithMetadata for T
[src]
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> I
[src]
impl<I> IteratorExt for I where
I: Iterator,
[src]
I: Iterator,
pub fn collect_<T>(self, PhantomData<fn() -> T>) -> T where
T: FromIterator<Self::Item>,
[src]
T: FromIterator<Self::Item>,
pub fn extending<C>(self, extend: &mut C) where
C: Extend<Self::Item>,
[src]
C: Extend<Self::Item>,
pub fn collect_into<C>(self, extend: C) -> C where
C: Extend<Self::Item>,
[src]
C: Extend<Self::Item>,
pub fn replace_nth(self, nth: usize, with: Self::Item) -> ReplaceNth<Self>
[src]
impl<T> SelfOps for T where
T: ?Sized,
[src]
T: ?Sized,
pub const T: PhantomData<fn() -> Self>
[src]
pub const T_D: PhantomData<Self>
[src]
pub fn assert_ty(self, _other: PhantomData<fn() -> Self>) -> Self
[src]
pub fn assert_ty_ref(&self, _other: PhantomData<fn() -> Self>) -> &Self
[src]
pub fn assert_ty_mut(&mut self, _other: PhantomData<fn() -> Self>) -> &mut Self
[src]
pub fn ty_(&self) -> PhantomData<fn() -> Self>
[src]
pub fn ty_d(&self) -> PhantomData<Self>
[src]
pub fn ty_inv(&self) -> PhantomData<fn(Self) -> Self>
[src]
pub fn ty_inv_ref(&self) -> PhantomData<Cell<&Self>>
[src]
pub fn eq_id(&self, other: &Self) -> bool
[src]
pub fn piped<F, U>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
pub fn piped_ref<'a, F, U>(&'a self, f: F) -> U where
F: FnOnce(&'a Self) -> U,
[src]
F: FnOnce(&'a Self) -> U,
pub fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U where
F: FnOnce(&'a mut Self) -> U,
[src]
F: FnOnce(&'a mut Self) -> U,
pub fn mutated<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
pub fn observe<F>(self, f: F) -> Self where
F: FnOnce(&Self),
[src]
F: FnOnce(&Self),
pub fn into_<T>(self, PhantomData<fn() -> T>) -> T where
Self: Into<T>,
[src]
Self: Into<T>,
pub fn as_ref_<T>(&self) -> &T where
Self: AsRef<T>,
T: ?Sized,
[src]
Self: AsRef<T>,
T: ?Sized,
pub fn as_mut_<T>(&mut self) -> &mut T where
Self: AsMut<T>,
T: ?Sized,
[src]
Self: AsMut<T>,
T: ?Sized,
pub fn drop_(self)
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<This> TransmuteElement for This where
This: ?Sized,
[src]
This: ?Sized,
pub unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
Self::Target: Sized,
[src]
Self: CanTransmuteElement<T>,
Self::Target: Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> TypeIdentity for T where
T: ?Sized,
[src]
T: ?Sized,
type Type = T
The same type as Self. Read more
pub fn into_type_val(self) -> Self::Type where
Self::Type: Sized,
[src]
Self::Type: Sized,
pub fn into_type_ref(&self) -> &Self::Type
[src]
pub fn into_type_mut(&mut self) -> &mut Self::Type
[src]
pub fn into_type_box(self: Box<Self, Global>) -> Box<Self::Type, Global>
[src]
pub fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
[src]
pub fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
[src]
pub fn from_type_val(this: Self::Type) -> Self where
Self::Type: Sized,
[src]
Self::Type: Sized,
pub fn from_type_ref(this: &Self::Type) -> &Self
[src]
pub fn from_type_mut(this: &mut Self::Type) -> &mut Self
[src]
pub fn from_type_box(this: Box<Self::Type, Global>) -> Box<Self, Global>
[src]
pub fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self>
[src]
pub fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>
[src]
impl<This> ValidTag_Bounds for This where
This: Debug + Clone + PartialEq<This>,
[src]
This: Debug + Clone + PartialEq<This>,