Class: OpenDAL::Lister
- Inherits:
-
Object
- Object
- OpenDAL::Lister
- Defined in:
- src/lister.rs
Overview
Represents the result when list a directory
This class is an enumerable.
Safety
Lister
is thread-safe.
Instance Method Summary collapse
-
#each ⇒ Entry
Returns the next element.
Instance Method Details
#each ⇒ Entry
Returns the next element.
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'src/lister.rs', line 115
fn each(&self) -> Result<Yield<Lister>, Error> {
// Magnus handles yielding to Ruby using an unsafe internal function,
// so we don’t manage the actual iteration loop ourselves.
//
// Since Ruby controls when values are pulled from the iterator,
// and could potentially call `each` from multiple threads or fibers,
// we wrap the underlying lister in `Arc<Mutex<_>>` to ensure thread safety.
//
// Multi-threaded iteration is rare in Ruby, but this design ensures thread safety.
Ok(Yield::Iter(Lister(self.0.clone())))
}
}
|