File tree Expand file tree Collapse file tree 6 files changed +57
-0
lines changed Expand file tree Collapse file tree 6 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ Added ` from_owned_fd ` constructor to ` PtyMaster/Fanotify/Inotify/SignalFd/TimerFd `
Original file line number Diff line number Diff line change @@ -52,6 +52,17 @@ pub enum ForkptyResult {
5252#[ derive( Debug ) ]
5353pub struct PtyMaster ( OwnedFd ) ;
5454
55+ impl PtyMaster {
56+ /// Constructs a `PytMaster` wrapping an existing `OwnedFd`.
57+ ///
58+ /// # Safety
59+ ///
60+ /// `OwnedFd` is a valid `PtyMaster`.
61+ pub unsafe fn from_owned_fd ( fd : OwnedFd ) -> Self {
62+ Self ( fd)
63+ }
64+ }
65+
5566impl AsRawFd for PtyMaster {
5667 fn as_raw_fd ( & self ) -> RawFd {
5768 self . 0 . as_raw_fd ( )
Original file line number Diff line number Diff line change @@ -423,4 +423,17 @@ impl From<Fanotify> for OwnedFd {
423423 fn from ( value : Fanotify ) -> Self {
424424 value. fd
425425 }
426+ }
427+
428+ impl Fanotify {
429+ /// Constructs a `Fanotify` wrapping an existing `OwnedFd`.
430+ ///
431+ /// # Safety
432+ ///
433+ /// `OwnedFd` is a valid `Fanotify`.
434+ pub unsafe fn from_owned_fd ( fd : OwnedFd ) -> Self {
435+ Self {
436+ fd
437+ }
438+ }
426439}
Original file line number Diff line number Diff line change @@ -239,6 +239,17 @@ impl Inotify {
239239
240240 Ok ( events)
241241 }
242+
243+ /// Constructs an `Inotify` wrapping an existing `OwnedFd`.
244+ ///
245+ /// # Safety
246+ ///
247+ /// `OwnedFd` is a valid `Inotify`.
248+ pub unsafe fn from_owned_fd ( fd : OwnedFd ) -> Self {
249+ Self {
250+ fd
251+ }
252+ }
242253}
243254
244255impl FromRawFd for Inotify {
Original file line number Diff line number Diff line change @@ -127,6 +127,15 @@ impl SignalFd {
127127 }
128128 }
129129
130+ /// Constructs a `SignalFd` wrapping an existing `OwnedFd`.
131+ ///
132+ /// # Safety
133+ ///
134+ /// `OwnedFd` is a valid `SignalFd`.
135+ pub unsafe fn from_owned_fd ( fd : OwnedFd ) -> Self {
136+ Self ( fd)
137+ }
138+
130139 fn update ( & self , mask : & SigSet , flags : SfdFlags ) -> Result < ( ) > {
131140 let raw_fd = self . 0 . as_raw_fd ( ) ;
132141 unsafe {
Original file line number Diff line number Diff line change @@ -225,4 +225,16 @@ impl TimerFd {
225225
226226 Ok ( ( ) )
227227 }
228+
229+
230+ /// Constructs a `TimerFd` wrapping an existing `OwnedFd`.
231+ ///
232+ /// # Safety
233+ ///
234+ /// `OwnedFd` is a valid `TimerFd`.
235+ pub unsafe fn from_owned_fd ( fd : OwnedFd ) -> Self {
236+ Self {
237+ fd
238+ }
239+ }
228240}
You can’t perform that action at this time.
0 commit comments