[−][src]Struct abi_stable::erased_types::dyn_trait::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.
trait InterfaceType
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 bellow.
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, 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> { get_module() .deserialize_foo()(s.get_rstr()) .into_result() } } #[repr(C)] #[derive(StableAbi)] #[sabi(kind(Prefix(prefix_struct="Module")))] #[sabi(missing_field(panic))] pub struct ModuleVal{ #[sabi(last_prefix_field)] pub deserialize_foo:extern "C" fn(s:RStr<'_>)->RResult<FooInterfaceBox,RBoxError>, } ///////////////////////////////////////////////////////////////////////////////////////// //// 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; }
Methods
impl DynTrait<'static, &'static (), ()>
[src]
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn from_value<T>(object: T) -> DynTrait<'static, RBox<()>, T::Interface> where
T: ImplType,
T::Interface: InterfaceBound,
T: GetVtable<'static, T, RBox<()>, RBox<T>, <T as ImplType>::Interface>,
[src]
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<_>
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn from_ptr<P, T>(
object: P
) -> DynTrait<'static, P::TransmutedPtr, T::Interface> 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> 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,
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<_>
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn from_any_value<T, I>(
object: T,
interface: I
) -> DynTrait<'static, RBox<()>, I> 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> where
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.
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn from_any_ptr<P, T, I>(
object: P,
_interface: I
) -> DynTrait<'static, P::TransmutedPtr, I> 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> 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,
Constructs the DynTrait<_>
from a pointer to a
type that doesn't borrow anything.
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn from_borrowing_value<'borr, T, I>(
object: T,
interface: I
) -> DynTrait<'borr, RBox<()>, I> 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> where
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.
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn from_borrowing_ptr<'borr, P, T, I>(
object: P,
_interface: I
) -> DynTrait<'borr, P::TransmutedPtr, I> 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> 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,
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 = ()>,
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn with_extra_value<OrigPtr, Unerasability>(
ptr: OrigPtr,
extra_value: EV
) -> DynTrait<'borr, P, I, EV> 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> where
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, StaticRef<EV>> where
P: GetPointerKind,
[src]
P: GetPointerKind,
pub fn sabi_et_vtable(&self) -> StaticRef<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,
pub fn sabi_erased_mut(&mut self) -> &mut ErasedObject where
P: DerefMut,
[src]
P: DerefMut,
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,
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,
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn reborrow<'re>(&'re self) -> DynTrait<'borr, &'re (), I, EV> where
P: Deref<Target = ()>,
PrivStruct: ReborrowBounds<I::Send, I::Sync>,
EV: Copy,
[src]
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
ⓘImportant traits for DynTrait<'borr, P, I, EV>pub fn reborrow_mut<'re>(&'re mut self) -> DynTrait<'borr, &'re mut (), I, EV> where
P: DerefMut<Target = ()>,
PrivStruct: ReborrowBounds<I::Send, I::Sync>,
EV: Copy,
[src]
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
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> GetStaticEquivalent_ for DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable<'borr, P, I>: SharedStableAbi,
[src]
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable<'borr, P, I>: SharedStableAbi,
type StaticEquivalent = _static_DynTrait<'static, __GetStaticEquivalent<P>, __GetStaticEquivalent<I>, __GetStaticEquivalent<EV>>
impl<'borr, P, I, EV> SharedStableAbi for DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable<'borr, P, I>: SharedStableAbi,
[src]
P: GetPointerKind,
P: __StableAbi,
I: __StableAbi,
EV: __StableAbi,
I: InterfaceBound,
VTable<'borr, P, I>: SharedStableAbi,
type IsNonZeroType = False
Whether this type has a single invalid bit-pattern. Read more
type Kind = __ValueKind
The kind of abi stability of this type,there are 2: Read more
const S_LAYOUT: &'static TypeLayout
[src]
const S_ABI_CONSTS: AbiConsts
[src]
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<'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> Drop for DynTrait<'borr, P, I, EV> where
P: GetPointerKind,
[src]
P: GetPointerKind,
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> 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> 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();
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
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,
fn next_back(&mut self) -> Option<Item>
[src]
fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]
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>,
fn rfold<B, F>(self, accum: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]
F: FnMut(B, Self::Item) -> B,
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<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>>,
fn partial_cmp(&self, other: &DynTrait<'static, P2, I, EV2>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.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>>,
fn eq(&self, other: &DynTrait<'static, P2, I, EV2>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
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,
fn cmp(&self, other: &Self) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
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.
fn next(&mut self) -> Option<Item>
[src]
fn nth(&mut self, nth: usize) -> Option<Item>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
fn count(self) -> usize
[src]
fn last(self) -> Option<Item>
[src]
fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]
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>,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]
U: IntoIterator,
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,
fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]
F: FnMut(Self::Item),
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]
P: FnMut(&Self::Item) -> bool,
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>,
fn enumerate(self) -> Enumerate<Self>
1.0.0[src]
fn peekable(self) -> Peekable<Self>
1.0.0[src]
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,
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,
fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]
fn take(self, n: usize) -> Take<Self>
1.0.0[src]
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>,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]
F: FnMut(Self::Item) -> U,
U: IntoIterator,
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]
Self::Item: IntoIterator,
fn fuse(self) -> Fuse<Self>
1.0.0[src]
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]
F: FnMut(&Self::Item),
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"]
fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]
B: FromIterator<Self::Item>,
fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]
P: FnMut(Self::Item) -> bool,
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>,
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 = ()>,
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,
fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
F: FnMut(Self::Item) -> bool,
fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]
F: FnMut(Self::Item) -> bool,
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,
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>,
fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]
P: FnMut(Self::Item) -> bool,
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
Self::Item: Ord,
fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]
Self::Item: Ord,
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]
B: Ord,
F: FnMut(&Self::Item) -> B,
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,
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]
B: Ord,
F: FnMut(&Self::Item) -> B,
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,
fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]
Self: DoubleEndedIterator,
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
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,
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,
fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]
Self: Clone,
fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]
S: Sum<Self::Item>,
fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]
P: Product<Self::Item>,
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,
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
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>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
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>,
fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
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>,
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>,
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>,
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>,
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>,
fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]
Self::Item: PartialOrd<Self::Item>,
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>,
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<'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>>,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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<'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, 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>>,
fn write_str(&mut self, s: &str) -> Result<(), Error>
[src]
fn write_char(&mut self, c: char) -> Result<(), Error>
1.1.0[src]
fn write_fmt(&mut self, args: Arguments) -> Result<(), Error>
1.0.0[src]
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>>,
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>
[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>>,
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>
1.36.0[src]
unsafe fn initializer(&self) -> Initializer
[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
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>>,
fn fill_buf(&mut self) -> Result<&[u8]>
[src]
fn consume(&mut self, ammount: usize)
[src]
fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn split(self, byte: u8) -> Split<Self>
1.0.0[src]
fn lines(self) -> Lines<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>>,
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
[src]
fn stream_len(&mut self) -> Result<u64, Error>
[src]
fn stream_position(&mut self) -> Result<u64, Error>
[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>>,
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
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<'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
.
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl<'borr, P, I, EV> Unpin for DynTrait<'borr, P, I, EV> where
EV: Unpin,
P: Unpin,
EV: Unpin,
P: Unpin,
impl<'borr, P, I, EV> UnwindSafe for DynTrait<'borr, P, I, EV> where
EV: UnwindSafe,
P: UnwindSafe,
EV: UnwindSafe,
P: UnwindSafe,
impl<'borr, P, I, EV = ()> !RefUnwindSafe for DynTrait<'borr, P, I, EV>
Blanket Implementations
impl<This> GetConstGenericVTable for This where
This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync,
[src]
This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync,
const VTABLE: ConstGenericVTableFor<This>
[src]
impl<This> StableAbi for This where
This: SharedStableAbi<Kind = ValueKind>,
[src]
This: SharedStableAbi<Kind = ValueKind>,
const LAYOUT: &'static TypeLayout
[src]
const ABI_CONSTS: AbiConsts
[src]
impl<This> TransmuteElement for This where
This: ?Sized,
[src]
This: ?Sized,
unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
Self::Target: Sized,
[src]
Self: CanTransmuteElement<T>,
Self::Target: Sized,
impl<'a, T> BorrowOwned<'a> for T where
T: 'a + Clone,
[src]
T: 'a + Clone,
type ROwned = T
type RBorrowed = &'a T
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
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
fn deref_borrowed(&<T as BorrowOwned<'a>>::RBorrowed) -> &T
[src]
fn deref_owned(&<T as BorrowOwned<'a>>::ROwned) -> &T
[src]
fn from_cow_borrow(&'a T) -> <T as BorrowOwned<'a>>::RBorrowed
[src]
fn from_cow_owned(<T as ToOwned>::Owned) -> <T as BorrowOwned<'a>>::ROwned
[src]
fn into_cow_borrow(<T as BorrowOwned<'a>>::RBorrowed) -> &'a T
[src]
fn into_cow_owned(<T as BorrowOwned<'a>>::ROwned) -> <T as ToOwned>::Owned
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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?
fn into_iter(self) -> I
[src]
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> TypeIdentity for T where
T: ?Sized,
[src]
T: ?Sized,
type Type = T
The same type as Self. Read more
fn into_type_val(self) -> Self::Type where
Self::Type: Sized,
[src]
Self::Type: Sized,
fn into_type_ref(&self) -> &Self::Type
[src]
fn into_type_mut(&mut self) -> &mut Self::Type
[src]
fn into_type_box(self: Box<Self>) -> Box<Self::Type>
[src]
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
[src]
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
[src]
fn from_type_val(this: Self::Type) -> Self where
Self::Type: Sized,
[src]
Self::Type: Sized,
fn from_type_ref(this: &Self::Type) -> &Self
[src]
fn from_type_mut(this: &mut Self::Type) -> &mut Self
[src]
fn from_type_box(this: Box<Self::Type>) -> Box<Self>
[src]
fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self>
[src]
fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>
[src]
impl<I> IteratorExt for I where
I: Iterator,
[src]
I: Iterator,
fn collect_<T>(self, PhantomData<fn() -> T>) -> T where
T: FromIterator<Self::Item>,
[src]
T: FromIterator<Self::Item>,
fn extending<C>(self, extend: &mut C) where
C: Extend<Self::Item>,
[src]
C: Extend<Self::Item>,
fn collect_into<C>(self, extend: C) -> C where
C: Extend<Self::Item>,
[src]
C: Extend<Self::Item>,
fn replace_nth(self, nth: usize, with: Self::Item) -> ReplaceNth<Self>
[src]
impl<T> SelfOps for T where
T: ?Sized,
[src]
T: ?Sized,
const T: PhantomData<fn() -> Self>
[src]
const T_D: PhantomData<Self>
[src]
fn assert_ty(self, _other: PhantomData<fn() -> Self>) -> Self
[src]
fn assert_ty_ref(&self, _other: PhantomData<fn() -> Self>) -> &Self
[src]
fn assert_ty_mut(&mut self, _other: PhantomData<fn() -> Self>) -> &mut Self
[src]
fn ty_(&self) -> PhantomData<fn() -> Self>
[src]
fn ty_d(&self) -> PhantomData<Self>
[src]
fn ty_inv(&self) -> PhantomData<fn(Self) -> Self>
[src]
fn ty_inv_ref(&self) -> PhantomData<Cell<&Self>>
[src]
fn eq_id(&self, other: &Self) -> bool
[src]
fn piped<F, U>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> U where
F: FnOnce(&'a Self) -> U,
[src]
F: FnOnce(&'a Self) -> U,
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,
fn mutated<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
fn observe<F>(self, f: F) -> Self where
F: FnOnce(&Self),
[src]
F: FnOnce(&Self),
fn into_<T>(self, PhantomData<fn() -> T>) -> T where
Self: Into<T>,
[src]
Self: Into<T>,
fn as_ref_<T>(&self) -> &T where
Self: AsRef<T>,
T: ?Sized,
[src]
Self: AsRef<T>,
T: ?Sized,
fn as_mut_<T>(&mut self) -> &mut T where
Self: AsMut<T>,
T: ?Sized,
[src]
Self: AsMut<T>,
T: ?Sized,
fn drop_(self)
[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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,