Struct smithay_client_toolkit::shm::raw::RawPool
source · pub struct RawPool { /* private fields */ }
Expand description
A raw handler for file backed shared memory pools.
This type of pool will create the SHM memory pool and provide a way to resize the pool.
This pool does not release buffers. If you need this, use one of the higher level pools.
Implementations§
source§impl RawPool
impl RawPool
pub fn new( len: usize, shm: &impl ProvidesBoundGlobal<WlShm, 1>, ) -> Result<RawPool, CreatePoolError>
sourcepub fn resize(&mut self, size: usize) -> Result<()>
pub fn resize(&mut self, size: usize) -> Result<()>
Resizes the memory pool, notifying the server the pool has changed in size.
The wl_shm protocol only allows the pool to be made bigger. If the new size is smaller than the current size of the pool, this function will do nothing.
sourcepub fn mmap(&mut self) -> &mut MmapMut
pub fn mmap(&mut self) -> &mut MmapMut
Returns a reference to the underlying shared memory file using the memmap2 crate.
sourcepub fn create_buffer<D, U>(
&mut self,
offset: i32,
width: i32,
height: i32,
stride: i32,
format: Format,
udata: U,
qh: &QueueHandle<D>,
) -> WlBuffer
pub fn create_buffer<D, U>( &mut self, offset: i32, width: i32, height: i32, stride: i32, format: Format, udata: U, qh: &QueueHandle<D>, ) -> WlBuffer
Create a new buffer to this pool.
§Parameters
offset
: the offset (in bytes) from the beginning of the pool at which this buffer starts.width
andheight
: the width and height of the buffer in pixels.stride
: distance (in bytes) between the beginning of a row and the next one.format
: the encoding format of the pixels.
The encoding format of the pixels must be supported by the compositor or else a protocol error is
risen. You can ensure the format is supported by listening to Shm::formats
.
Note this function only creates the wl_buffer object, you will need to write to the pixels using the
io::Write
implementation or RawPool::mmap
.
sourcepub fn create_buffer_raw(
&mut self,
offset: i32,
width: i32,
height: i32,
stride: i32,
format: Format,
data: Arc<dyn ObjectData + 'static>,
) -> WlBuffer
pub fn create_buffer_raw( &mut self, offset: i32, width: i32, height: i32, stride: i32, format: Format, data: Arc<dyn ObjectData + 'static>, ) -> WlBuffer
Create a new buffer to this pool.
This is identical to Self::create_buffer, but allows using a custom ObjectData implementation instead of relying on the Dispatch interface.
Trait Implementations§
source§impl Seek for RawPool
impl Seek for RawPool
source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len
)source§impl Write for RawPool
impl Write for RawPool
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Auto Trait Implementations§
impl Freeze for RawPool
impl !RefUnwindSafe for RawPool
impl Send for RawPool
impl Sync for RawPool
impl Unpin for RawPool
impl !UnwindSafe for RawPool
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.