Skip to main content

FromZval

Trait FromZval 

Source
pub trait FromZval<'a>: Sized {
    const TYPE: DataType;
    const NULLABLE: bool = false;

    // Required method
    fn from_zval(zval: &'a Zval) -> Option<Self>;

    // Provided method
    fn from_missing() -> Option<Self> { ... }
}
Expand description

Allows zvals to be converted into Rust types in a fallible way. Reciprocal of the IntoZval trait.

Required Associated Constants§

Source

const TYPE: DataType

The corresponding type of the implemented value in PHP.

Provided Associated Constants§

Source

const NULLABLE: bool = false

Whether a PHP argument of this type accepts null and may be omitted.

Drives the ?T nullability bit and the optional position of a parameter declared with this type.

Required Methods§

Source

fn from_zval(zval: &'a Zval) -> Option<Self>

Attempts to retrieve an instance of Self from a reference to a Zval.

§Parameters
  • zval - Zval to get value from.

Provided Methods§

Source

fn from_missing() -> Option<Self>

The value to use when a PHP argument of this type was omitted by the caller. None means the argument is required.

It must return Some exactly when NULLABLE is true. The macros decide from NULLABLE alone which parameters PHP callers may omit.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromZval<'_> for String

Source§

const TYPE: DataType = crate::flags::DataType::String

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for bool

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for f32

Source§

const TYPE: DataType = DataType::Double

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for f64

Source§

const TYPE: DataType = DataType::Double

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for i8

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for i16

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for i32

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for i64

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for isize

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for u8

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for u16

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for u32

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for u64

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl FromZval<'_> for usize

Source§

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

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Source§

impl<'a, K, V, H> FromZval<'a> for HashMap<K, V, H>
where K: TryFrom<ArrayKey<'a>, Error = Error> + Hash + Eq, V: FromZval<'a>, H: BuildHasher + Default,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, K, V, H> FromZval<'a> for IndexMap<K, V, H>
where K: TryFrom<ArrayKey<'a>, Error = Error> + Hash + Eq, V: FromZval<'a>, H: BuildHasher + Default,

Available on crate feature indexmap only.
Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, K, V> FromZval<'a> for BTreeMap<K, V>
where K: TryFrom<ArrayKey<'a>, Error = Error> + Ord, V: FromZval<'a>,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, K, V> FromZval<'a> for Vec<(K, V)>
where K: TryFrom<ArrayKey<'a>, Error = Error>, V: FromZval<'a>,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, T> FromZval<'a> for Option<T>
where T: FromZval<'a>,

Source§

const TYPE: DataType = T::TYPE

Source§

const NULLABLE: bool = true

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

fn from_missing() -> Option<Self>

Source§

impl<'a, T> FromZval<'a> for Vec<T>
where T: FromZval<'a>,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V, H> FromZval<'a> for HashMap<ArrayKey<'a>, V, H>
where V: FromZval<'a>, H: BuildHasher + Default,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V, H> FromZval<'a> for HashSet<V, H>
where V: FromZval<'a> + Eq + Hash, H: BuildHasher + Default,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V, H> FromZval<'a> for IndexMap<ArrayKey<'a>, V, H>
where V: FromZval<'a>, H: BuildHasher + Default,

Available on crate feature indexmap only.
Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V, H> FromZval<'a> for IndexSet<V, H>
where V: FromZval<'a> + Eq + Hash, H: BuildHasher + Default,

Available on crate feature indexmap only.
Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V> FromZval<'a> for BTreeMap<ArrayKey<'a>, V>
where V: FromZval<'a>,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V> FromZval<'a> for BTreeSet<V>
where V: FromZval<'a> + Ord,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a, V> FromZval<'a> for Vec<(ArrayKey<'a>, V)>
where V: FromZval<'a>,

Source§

const TYPE: DataType = DataType::Array

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<'a> FromZval<'a> for &'a str

Source§

const TYPE: DataType = DataType::String

Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

Source§

impl<M: SmartStringMode> FromZval<'_> for SmartString<M>

Available on crate feature smartstring only.
Source§

const TYPE: DataType = DataType::String

Source§

fn from_zval(zval: &Zval) -> Option<Self>

Implementors§

Source§

impl<'a, T: RegisteredClass> FromZval<'a> for &'a ZendClassObject<T>

Source§

impl<'a, T> FromZval<'a> for BinarySlice<'a, T>
where T: PackSlice,

Source§

const TYPE: DataType = DataType::String

Source§

impl<'a> FromZval<'a> for &'a Closure

Available on crate feature closure only.
Source§

impl<'a> FromZval<'a> for &'a ZendHashTable

Source§

const TYPE: DataType = DataType::Array

Source§

impl<'a> FromZval<'a> for &'a ZendObject

Source§

const TYPE: DataType = DataType::ANY_OBJECT

Source§

impl<'a> FromZval<'a> for &'a Zval

Source§

const TYPE: DataType = DataType::Mixed

Source§

impl<'a> FromZval<'a> for ArrayKey<'_>

Source§

const TYPE: DataType = DataType::String

Source§

impl<'a> FromZval<'a> for ZendCallable<'a>

Source§

const TYPE: DataType = DataType::Callable

Source§

impl<T: Pack> FromZval<'_> for Binary<T>

Source§

const TYPE: DataType = DataType::String

Source§

impl<T> FromZval<'_> for T

Available on crate feature enum only.