Skip to content

Commit

Permalink
unix_streams: Rename and remove unsafe version
Browse files Browse the repository at this point in the history
  • Loading branch information
A6GibKm committed Jun 10, 2024
1 parent 578ed66 commit bf6f65d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
14 changes: 1 addition & 13 deletions gio/src/unix_input_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,13 @@ impl UnixInputStream {
// rustdoc-stripper-ignore-next
/// Creates a new [`Self`] that takes ownership of the passed in fd.
#[doc(alias = "g_unix_input_stream_new")]
pub fn take_fd(fd: OwnedFd) -> UnixInputStream {
pub fn from_fd(fd: OwnedFd) -> UnixInputStream {
let fd = fd.into_raw_fd();
let close_fd = true.into_glib();
unsafe {
InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast()
}
}

// rustdoc-stripper-ignore-next
/// Creates a new [`Self`] that does not take ownership of the passed in fd.
///
/// # Safety
/// You may only close the fd if all references to this stream have been dropped.
#[doc(alias = "g_unix_input_stream_new")]
pub unsafe fn with_fd<T: AsRawFd>(fd: T) -> UnixInputStream {
let fd = fd.as_raw_fd();
let close_fd = false.into_glib();
InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast()
}
}

impl AsRawFd for UnixInputStream {
Expand Down
14 changes: 1 addition & 13 deletions gio/src/unix_output_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,13 @@ impl UnixOutputStream {
// rustdoc-stripper-ignore-next
/// Creates a new [`Self`] that takes ownership of the passed in fd.
#[doc(alias = "g_unix_output_stream_new")]
pub fn take_fd(fd: OwnedFd) -> UnixOutputStream {
pub fn from_fd(fd: OwnedFd) -> UnixOutputStream {
let fd = fd.into_raw_fd();
let close_fd = true.into_glib();
unsafe {
OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast()
}
}

// rustdoc-stripper-ignore-next
/// Creates a new [`Self`] that does not take ownership of the passed in fd.
///
/// # Safety
/// You may only close the fd if all references to this stream have been dropped.
#[doc(alias = "g_unix_output_stream_new")]
pub unsafe fn with_fd<T: AsRawFd>(fd: T) -> UnixOutputStream {
let fd = fd.as_raw_fd();
let close_fd = false.into_glib();
OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast()
}
}

impl AsRawFd for UnixOutputStream {
Expand Down

0 comments on commit bf6f65d

Please sign in to comment.