Skip to content

Commit

Permalink
Implement AsFd for RawPool
Browse files Browse the repository at this point in the history
Makes sense to provide alongside `Write` and `Seek`, and useful for
using shm buffers with other protocols like Pipewire.

`SlotPool` can't provide this, as a safe accessor.
  • Loading branch information
ids1024 authored and wash2 committed Dec 18, 2024
1 parent 048c245 commit a9e8607
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/shm/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustix::{
use std::{
fs::File,
io,
os::unix::prelude::{AsFd, OwnedFd},
os::unix::prelude::{AsFd, BorrowedFd, OwnedFd},
sync::Arc,
time::{SystemTime, UNIX_EPOCH},
};
Expand Down Expand Up @@ -151,6 +151,12 @@ impl RawPool {
}
}

impl AsFd for RawPool {
fn as_fd(&self) -> BorrowedFd {
self.mem_file.as_fd()
}
}

impl io::Write for RawPool {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
io::Write::write(&mut self.mem_file, buf)
Expand Down

0 comments on commit a9e8607

Please sign in to comment.