pub unsafe trait PboOps: Send + Sync {
// Required methods
fn map_buffer(&self, buffer_id: u32, size: usize) -> Result<PboMapping>;
fn unmap_buffer(&self, buffer_id: u32) -> Result<()>;
fn delete_buffer(&self, buffer_id: u32);
}Expand description
Trait for PBO GL operations, implemented by the image crate.
All methods are blocking. Implementations must ensure the GL context is current on the thread that executes the actual GL calls — by sending to the GL worker, or by running inline when the caller already IS that worker.
§Safety
Implementations must ensure:
map_bufferreturns a valid, aligned pointer tosizebytes of CPU-accessible memory that remains valid untilunmap_bufferis called.unmap_bufferinvalidates the pointer and releases the mapping.delete_bufferfrees the GL buffer resources.- No method unwinds.
PboHandle::acquire_mappublishesMapState::Mappingbefore callingmap_bufferand clears it only on return, so a panic crossing this boundary strands that handle and every later map on it waits on the condvar forever.
Required Methods§
Sourcefn map_buffer(&self, buffer_id: u32, size: usize) -> Result<PboMapping>
fn map_buffer(&self, buffer_id: u32, size: usize) -> Result<PboMapping>
Map the PBO for CPU read/write access.
The returned PboMapping is valid until unmap_buffer is called.
A returned PboMapping::size below size is treated as a FAILED
map, not a partial one: PboHandle::acquire_map refuses it and
unmaps the buffer. Callers of the resulting pin size their host
slice from the tensor’s own allocation, so there is nowhere for a
shorter mapping to be recorded. Report the shortfall as an Err
rather than a short success if the implementation can tell.
Sourcefn unmap_buffer(&self, buffer_id: u32) -> Result<()>
fn unmap_buffer(&self, buffer_id: u32) -> Result<()>
Unmap a previously mapped PBO. Must be called before GL operations on this buffer (GLES 3.0 requirement).
Sourcefn delete_buffer(&self, buffer_id: u32)
fn delete_buffer(&self, buffer_id: u32)
Delete the PBO. Fire-and-forget — no reply needed. Called from PboTensor’s Drop impl.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".