Skip to main content

ZBox

Struct ZBox 

Source
pub struct ZBox<T: ZBoxable>(/* private fields */);
Expand description

A pointer type for heap allocation using the Zend memory manager.

See the module level documentation for more.

Implementations§

Source§

impl<T: ZBoxable> ZBox<T>

Source

pub unsafe fn from_raw(ptr: *mut T) -> Self

Creates a new box from a given pointer.

§Parameters
  • ptr - A non-null, well-aligned pointer to a T.
§Safety

Caller must ensure that ptr is non-null, well-aligned and pointing to a T.

Source

pub fn into_raw(self) -> *mut T

Returns the pointer contained by the box, dropping the box in the process. The data pointed to by the returned pointer is not released.

Mirrors Box::into_raw: the pointer is non-null and well-aligned, and the caller becomes responsible for releasing it, typically by passing it back to ZBox::from_raw or to the engine.

Trait Implementations§

Source§

impl<T: ZBoxable> AsRef<T> for ZBox<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: ZBoxable> Borrow<T> for ZBox<T>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl Clone for ZBox<ZendHashTable>

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: RegisteredClass + Clone> Clone for ZBox<ZendClassObject<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: ZBoxable + Debug> Debug for ZBox<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ZBox<ZendHashTable>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: RegisteredClass + Default> Default for ZBox<ZendClassObject<T>>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: ZBoxable> Deref for ZBox<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: ZBoxable> DerefMut for ZBox<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: ZBoxable> Drop for ZBox<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<'a> From<&'a ZBox<_zend_string>> for ArrayKey<'a>

Source§

fn from(value: &'a ZBox<ZendStr>) -> Self

Converts to this type from the input type.
Source§

impl From<&CStr> for ZBox<ZendStr>

Source§

fn from(value: &CStr) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for ZBox<ZendStr>

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<CString> for ZBox<ZendStr>

Source§

fn from(value: CString) -> Self

Converts to this type from the input type.
Source§

impl From<Cow<'_, _zend_string>> for ZBox<ZendStr>

Source§

fn from(value: Cow<'_, ZendStr>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ZBox<ZendStr>

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl<T: RegisteredClass> From<ZBox<ZendClassObject<T>>> for ZBox<ZendObject>

Source§

fn from(obj: ZBox<ZendClassObject<T>>) -> Self

Converts to this type from the input type.
Source§

impl From<ZBox<_zend_string>> for Cow<'_, ZendStr>

Source§

fn from(value: ZBox<ZendStr>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<(&'a str, _zval_struct)> for ZBox<ZendHashTable>

Source§

fn from_iter<T: IntoIterator<Item = (&'a str, Zval)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<(i64, _zval_struct)> for ZBox<ZendHashTable>

Source§

fn from_iter<T: IntoIterator<Item = (i64, Zval)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<_zval_struct> for ZBox<ZendHashTable>

Source§

fn from_iter<T: IntoIterator<Item = Zval>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl IntoZval for ZBox<ZendHashTable>

Source§

const TYPE: DataType = DataType::Array

The corresponding type of the implemented value in PHP.
Source§

const NULLABLE: bool = false

Whether converting into a Zval may result in null.
Source§

fn set_zval(self, zv: &mut Zval, _: bool) -> Result<()>

Sets the content of a pre-existing zval. Returns a result containing nothing if setting the content was successful. Read more
Source§

fn into_zval(self, persistent: bool) -> Result<Zval>

Converts a Rust primitive type into a Zval. Returns a result containing the Zval if successful. Read more
Source§

impl<T: RegisteredClass> IntoZval for ZBox<ZendClassObject<T>>

Source§

const TYPE: DataType

The corresponding type of the implemented value in PHP.
Source§

const NULLABLE: bool = false

Whether converting into a Zval may result in null.
Source§

fn set_zval(self, zv: &mut Zval, _: bool) -> Result<()>

Sets the content of a pre-existing zval. Returns a result containing nothing if setting the content was successful. Read more
Source§

fn into_zval(self, persistent: bool) -> Result<Zval>

Converts a Rust primitive type into a Zval. Returns a result containing the Zval if successful. Read more
Source§

impl IntoZval for ZBox<ZendObject>

Source§

const TYPE: DataType = DataType::ANY_OBJECT

The corresponding type of the implemented value in PHP.
Source§

const NULLABLE: bool = false

Whether converting into a Zval may result in null.
Source§

fn set_zval(self, zv: &mut Zval, _: bool) -> Result<()>

Sets the content of a pre-existing zval. Returns a result containing nothing if setting the content was successful. Read more
Source§

fn into_zval(self, persistent: bool) -> Result<Zval>

Converts a Rust primitive type into a Zval. Returns a result containing the Zval if successful. Read more
Source§

impl<'a, K, V> TryFrom<BTreeMap<K, V>> for ZBox<ZendHashTable>
where K: Into<ArrayKey<'a>>, V: IntoZval,

Source§

type Error = Error

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

fn try_from(value: BTreeMap<K, V>) -> Result<Self>

Performs the conversion.
Source§

impl<V> TryFrom<BTreeSet<V>> for ZBox<ZendHashTable>
where V: IntoZval,

Source§

type Error = Error

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

fn try_from(value: BTreeSet<V>) -> Result<Self>

Performs the conversion.
Source§

impl<'a, K, V, H> TryFrom<HashMap<K, V, H>> for ZBox<ZendHashTable>
where K: Into<ArrayKey<'a>>, V: IntoZval, H: BuildHasher + Default,

Source§

type Error = Error

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

fn try_from(value: HashMap<K, V, H>) -> Result<Self>

Performs the conversion.
Source§

impl<V, H> TryFrom<HashSet<V, H>> for ZBox<ZendHashTable>
where V: IntoZval, H: BuildHasher,

Source§

type Error = Error

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

fn try_from(value: HashSet<V, H>) -> Result<Self>

Performs the conversion.
Source§

impl<'a, K, V, H> TryFrom<IndexMap<K, V, H>> for ZBox<ZendHashTable>
where K: Into<ArrayKey<'a>>, V: IntoZval, H: BuildHasher + Default,

Available on crate feature indexmap only.
Source§

type Error = Error

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

fn try_from(value: IndexMap<K, V, H>) -> Result<Self>

Performs the conversion.
Source§

impl<V, H> TryFrom<IndexSet<V, H>> for ZBox<ZendHashTable>
where V: IntoZval, H: BuildHasher,

Available on crate feature indexmap only.
Source§

type Error = Error

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

fn try_from(value: IndexSet<V, H>) -> Result<Self>

Performs the conversion.
Source§

impl<'a, K, V> TryFrom<Vec<(K, V)>> for ZBox<ZendHashTable>
where K: Into<ArrayKey<'a>>, V: IntoZval,

Source§

type Error = Error

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

fn try_from(value: Vec<(K, V)>) -> Result<Self>

Performs the conversion.
Source§

impl<T> TryFrom<Vec<T>> for ZBox<ZendHashTable>
where T: IntoZval,

Source§

type Error = Error

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

fn try_from(value: Vec<T>) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl<T> !Send for ZBox<T>

§

impl<T> !Sync for ZBox<T>

§

impl<T> Freeze for ZBox<T>
where NonNull<T>: Freeze,

§

impl<T> RefUnwindSafe for ZBox<T>

§

impl<T> Unpin for ZBox<T>
where NonNull<T>: Unpin,

§

impl<T> UnsafeUnpin for ZBox<T>
where NonNull<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for ZBox<T>
where NonNull<T>: UnwindSafe,

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> IntoZvalDyn for T
where T: IntoZval + Clone,

Source§

fn as_zval(&self, persistent: bool) -> Result<_zval_struct, Error>

Converts a Rust primitive type into a Zval. Returns a result containing the Zval if successful. self is cloned before being converted into a zval. Read more
Source§

fn get_type(&self) -> DataType

Returns the PHP type of the type.
Source§

fn stub_value(&self) -> String

Returns the PHP stub representation of this value. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.