ext_php_rs/types/
mod.rs

1//! Types defined by the Zend engine used in PHP.
2//!
3//! Generally, it is easier to work directly with Rust types, converting into
4//! these PHP types when required.
5
6mod array;
7mod callable;
8mod class_object;
9mod iterable;
10mod iterator;
11mod long;
12mod object;
13mod string;
14mod zval;
15
16pub use array::{ArrayKey, ZendHashTable};
17pub use callable::ZendCallable;
18pub use class_object::ZendClassObject;
19pub use iterable::Iterable;
20pub use iterator::ZendIterator;
21pub use long::ZendLong;
22pub use object::{PropertyQuery, ZendObject};
23pub use string::ZendStr;
24pub use zval::Zval;
25
26use crate::{convert::FromZval, flags::DataType, macros::into_zval};
27
28into_zval!(f32, set_double, Double);
29into_zval!(f64, set_double, Double);
30into_zval!(bool, set_bool, Bool);
31
32try_from_zval!(f64, double, Double);
33try_from_zval!(bool, bool, Bool);
34
35impl FromZval<'_> for f32 {
36    const TYPE: DataType = DataType::Double;
37
38    fn from_zval(zval: &Zval) -> Option<Self> {
39        zval.double().map(|v| v as f32)
40    }
41}