Trait IntoZval

Source
pub trait IntoZval: Sized {
    const TYPE: DataType;
    const NULLABLE: bool;

    // Required method
    fn set_zval(self, zv: &mut Zval, persistent: bool) -> Result<()>;

    // Provided method
    fn into_zval(self, persistent: bool) -> Result<Zval> { ... }
}
Expand description

Provides implementations for converting Rust primitive types into PHP zvals. Alternative to the built-in Rust From and TryFrom implementations, allowing the caller to specify whether the Zval contents will persist between requests.

Required Associated Constants§

Source

const TYPE: DataType

The corresponding type of the implemented value in PHP.

Source

const NULLABLE: bool

Whether converting into a Zval may result in null.

Required Methods§

Source

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

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

§Parameters
  • zv - The Zval to set the content of.
  • persistent - Whether the contents of the Zval will persist between requests.
§Errors

If setting the content fails, an Error is returned.

Provided Methods§

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.

§Parameters
  • persistent - Whether the contents of the Zval will persist between requests.
§Errors

If the conversion fails, an Error is returned.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl IntoZval for &str

Source§

const TYPE: DataType = DataType::String

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for bool

Source§

const TYPE: DataType = crate::flags::DataType::Bool

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for f32

Source§

const TYPE: DataType = crate::flags::DataType::Double

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for f64

Source§

const TYPE: DataType = crate::flags::DataType::Double

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for i8

Source§

const TYPE: DataType = crate::flags::DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for i16

Source§

const TYPE: DataType = crate::flags::DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for i32

Source§

const TYPE: DataType = crate::flags::DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for i64

Source§

const TYPE: DataType = DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for isize

Source§

const TYPE: DataType = DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for u8

Source§

const TYPE: DataType = crate::flags::DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for u16

Source§

const TYPE: DataType = crate::flags::DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for u32

Source§

const TYPE: DataType = DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for u64

Source§

const TYPE: DataType = DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for ()

Source§

const TYPE: DataType = DataType::Void

Source§

const NULLABLE: bool = true

Source§

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

Source§

impl IntoZval for usize

Source§

const TYPE: DataType = DataType::Long

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl IntoZval for String

Source§

const TYPE: DataType = DataType::String

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl<K, V> IntoZval for HashMap<K, V>
where K: AsRef<str>, V: IntoZval,

Source§

const TYPE: DataType = DataType::Array

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl<T> IntoZval for Option<T>
where T: IntoZval,

Source§

const TYPE: DataType = T::TYPE

Source§

const NULLABLE: bool = true

Source§

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

Source§

impl<T> IntoZval for Vec<T>
where T: IntoZval,

Source§

const TYPE: DataType = DataType::Array

Source§

const NULLABLE: bool = false

Source§

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

Source§

impl<T, E> IntoZval for Result<T, E>
where T: IntoZval, E: Into<PhpException>,

Source§

const TYPE: DataType = T::TYPE

Source§

const NULLABLE: bool = T::NULLABLE

Source§

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

Implementors§

Source§

impl IntoZval for &mut ZendObject

Source§

impl IntoZval for ZBox<ZendHashTable>

Source§

const TYPE: DataType = DataType::Array

Source§

const NULLABLE: bool = false

Source§

impl IntoZval for ZBox<ZendObject>

Source§

impl IntoZval for Closure

Available on crate feature closure only.
Source§

impl IntoZval for Zval

Source§

const TYPE: DataType = DataType::Mixed

Source§

const NULLABLE: bool = true

Source§

impl<T: Pack> IntoZval for Binary<T>

Source§

const TYPE: DataType = DataType::String

Source§

const NULLABLE: bool = false

Source§

impl<T: RegisteredClass> IntoZval for &mut ZendClassObject<T>

Source§

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