Type Alias ext_php_rs::types::ZendIterator

source ·
pub type ZendIterator = zend_object_iterator;
Expand description

A PHP Iterator.

In PHP, iterators are represented as zend_object_iterator. This allows user to iterate over objects implementing Traversable interface using foreach.

Use ZendIterable to iterate over both iterators and arrays.

Aliased Type§

struct ZendIterator {
    pub std: _zend_object,
    pub data: _zval_struct,
    pub funcs: *const _zend_object_iterator_funcs,
    pub index: u64,
}

Fields§

§std: _zend_object§data: _zval_struct§funcs: *const _zend_object_iterator_funcs§index: u64

Implementations§

source§

impl ZendIterator

source

pub fn iter(&mut self) -> Option<Iter<'_>>

Creates a new rust iterator from a zend_object_iterator.

Returns a iterator over the zend_object_iterator, or None if the iterator cannot be rewound.

source

pub fn valid(&mut self) -> bool

Check if the current position of the iterator is valid.

As an example this will call the user defined valid method of the [‘\Iterator’] interface. see https://www.php.net/manual/en/iterator.valid.php

source

pub fn rewind(&mut self) -> bool

Rewind the iterator to the first element.

As an example this will call the user defined rewind method of the [‘\Iterator’] interface. see https://www.php.net/manual/en/iterator.rewind.php

§Returns

Returns true if the iterator was successfully rewind, false otherwise. (when there is an exception during rewind)

source

pub fn move_forward(&mut self) -> bool

Move the iterator forward to the next element.

As an example this will call the user defined next method of the [‘\Iterator’] interface. see https://www.php.net/manual/en/iterator.next.php

§Returns

Returns true if the iterator was successfully move, false otherwise. (when there is an exception during next)

source

pub fn get_current_data<'a>(&mut self) -> Option<&'a Zval>

Get the current data of the iterator.

§Returns

Returns a reference to the current data of the iterator if available , [‘None’] otherwise.

source

pub fn get_current_key(&mut self) -> Option<Zval>

Get the current key of the iterator.

§Returns

Returns a new [‘Zval’] containing the current key of the iterator if available , [‘None’] otherwise.

Trait Implementations§

source§

impl Debug for ZendIterator

source§

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

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

impl<'a> FromZvalMut<'a> for &'a mut ZendIterator

source§

const TYPE: DataType = _

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

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

Attempts to retrieve an instance of Self from a mutable reference to a Zval. Read more
source§

impl<'a> IntoIterator for &'a mut ZendIterator

§

type Item = (_zval_struct, &'a _zval_struct)

The type of the elements being iterated over.
§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more