Skip to main content

Wire

Struct Wire 

Source
pub struct Wire<T>
where T: ?Sized,
{ /* private fields */ }
Expand description

Wraps and transfers complex objects over FFI.

The backing storage uses a (ptr, size) representation that can safely cross FFI boundaries. See the module documentation for more details and examples.

Implementations§

Source§

impl<T: TypeInfo + WireIO> Wire<T>

Source

pub fn try_from(value: T) -> Result<Self, SerializationError>

Serialize value into a new owned Wire.

§Errors

Returns SerializationError if value cannot be serialized into the buffer.

Source

pub fn from(value: T) -> Self

Serialize value into a new owned Wire.

§Panics

Panics at compile time if T::WIRE_SAFE is false.

Source

pub fn try_unwire(&mut self) -> Result<T, SerializationError>

Deserialize the value from this Wire’s buffer.

§Errors

Returns SerializationError if the buffer contents cannot be deserialized into T (e.g., truncated buffer, malformed data).

Source

pub fn unwire(&mut self) -> T

Deserialize the value from this Wire’s buffer.

§Panics

Panics at compile time if T::WIRE_SAFE is false.

Trait Implementations§

Source§

impl<T: ?Sized> Clone for Wire<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: TypeInfo + WireIO> TypeInfo for Wire<T>

Source§

const WIRE_SAFE: bool = false

Whether this type can be used inside a Wire<T>.
Source§

const RAW_SAFE: bool = true

Whether this type can be passed directly over the FFI boundary.
Source§

const ASYNC_SAFE: bool = true

Whether this type can appear in an async service method.
Source§

const SERVICE_SAFE: bool = true

Whether this type can appear in a service method.
Source§

const SERVICE_CTOR_SAFE: bool = true

Whether this type is valid as a service constructor return type.
Source§

fn id() -> TypeId

The unique identifier for this type.
Source§

fn kind() -> TypeKind

The structural kind of this type.
Source§

fn ty() -> Type

The full type description.
Source§

fn register(inventory: &mut impl Inventory)

Registers this type and all its transitive dependencies with the inventory.
Source§

const OPTION_PTR_SAFE: bool = false

Whether std::Option<Self> uses a niche and is FFI-safe as a pointer (e.g., references, NonNull, function pointers).
Source§

impl<T: WireIO> WireIO for Wire<T>

Source§

fn write(&self, _: &mut impl Write) -> Result<(), SerializationError>

Serializes this value into the writer.
Source§

fn read(_: &mut impl Read) -> Result<Self, SerializationError>

Deserializes a value from the reader.
Source§

fn live_size(&self) -> usize

Returns the serialized size of this value in bytes.

Auto Trait Implementations§

§

impl<T> Freeze for Wire<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for Wire<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for Wire<T>
where T: Send + ?Sized,

§

impl<T> Sync for Wire<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for Wire<T>
where T: Unpin + ?Sized,

§

impl<T> UnsafeUnpin for Wire<T>
where T: ?Sized,

§

impl<T> UnwindSafe for Wire<T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.