Skip to content

Commit

Permalink
Use std::io::Error instead of rustix::io::Error in the public API.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Jan 27, 2022
1 parent db960f5 commit 2c3f756
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use std::fmt;
#[derive(Debug)]
pub enum Error {
/// Cannot create the memfd
Create(rustix::io::Error),
Create(std::io::Error),
/// Cannot add new seals to the memfd
AddSeals(rustix::io::Error),
AddSeals(std::io::Error),
/// Cannot read the seals of a memfd
GetSeals(rustix::io::Error),
GetSeals(std::io::Error),
}

impl std::error::Error for Error {
Expand Down
12 changes: 9 additions & 3 deletions src/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ impl MemfdOptions {
/// [`Memfd`]: Memfd
pub fn create<T: AsRef<str>>(&self, name: T) -> Result<Memfd, crate::Error> {
let flags = self.bitflags();
let fd = rustix::fs::memfd_create(name.as_ref(), flags).map_err(crate::Error::Create)?;
let fd = rustix::fs::memfd_create(name.as_ref(), flags)
.map_err(Into::into)
.map_err(crate::Error::Create)?;
Ok(Memfd {
file: rustix::fd::FromFd::from_fd(fd.into()),
})
Expand Down Expand Up @@ -191,13 +193,17 @@ impl Memfd {
/// Add some seals to the existing set of seals.
pub fn add_seals(&self, seals: &sealing::SealsHashSet) -> Result<(), crate::Error> {
let flags = sealing::seals_to_bitflags(seals);
rustix::fs::fcntl_add_seals(&self.file, flags).map_err(crate::Error::AddSeals)?;
rustix::fs::fcntl_add_seals(&self.file, flags)
.map_err(Into::into)
.map_err(crate::Error::AddSeals)?;
Ok(())
}

/// Return the current sealing bitflags.
fn file_get_seals(fp: &fs::File) -> Result<SealFlags, crate::Error> {
let r = rustix::fs::fcntl_get_seals(fp).map_err(crate::Error::GetSeals)?;
let r = rustix::fs::fcntl_get_seals(fp)
.map_err(Into::into)
.map_err(crate::Error::GetSeals)?;
Ok(r)
}
}
Expand Down

0 comments on commit 2c3f756

Please sign in to comment.