@@ -30,7 +30,8 @@ pub struct Attacher<S> {
3030}
3131
3232impl < S : AsRawFd > Attacher < S > {
33- /// Create [`Attacher`].
33+ /// Create [`Attacher`]. It tries to attach the source, and will return
34+ /// [`Err`] if it fails.
3435 pub fn new ( source : S ) -> io:: Result < Self > {
3536 let this = Self {
3637 source,
@@ -41,7 +42,7 @@ impl<S: AsRawFd> Attacher<S> {
4142 }
4243
4344 /// Attach the source. This method could be called many times, but if the
44- /// action fails, the error will only return once .
45+ /// action fails, it will try to attach the source during each call .
4546 fn attach ( & self ) -> io:: Result < ( ) > {
4647 let r = Runtime :: current ( ) ;
4748 let inner = r. inner ( ) ;
@@ -51,12 +52,6 @@ impl<S: AsRawFd> Attacher<S> {
5152 }
5253}
5354
54- impl < S > Attachable for Attacher < S > {
55- fn is_attached ( & self ) -> bool {
56- self . once . get ( ) . is_some ( )
57- }
58- }
59-
6055impl < S : IntoRawFd > IntoRawFd for Attacher < S > {
6156 fn into_raw_fd ( self ) -> RawFd {
6257 self . source . into_raw_fd ( )
@@ -106,12 +101,6 @@ impl<S> DerefMut for Attacher<S> {
106101 }
107102}
108103
109- /// Represents an attachable resource to driver.
110- pub trait Attachable {
111- /// Check if [`Attachable::attach`] has been called.
112- fn is_attached ( & self ) -> bool ;
113- }
114-
115104/// Duplicatable file or socket.
116105pub trait TryClone : Sized {
117106 /// Duplicate the source.
@@ -151,18 +140,6 @@ impl TryClone for OwnedFd {
151140 }
152141}
153142
154- #[ macro_export]
155- #[ doc( hidden) ]
156- macro_rules! impl_attachable {
157- ( $t: ty, $inner: ident) => {
158- impl $crate:: Attachable for $t {
159- fn is_attached( & self ) -> bool {
160- self . $inner. is_attached( )
161- }
162- }
163- } ;
164- }
165-
166143#[ macro_export]
167144#[ doc( hidden) ]
168145macro_rules! impl_try_clone {
0 commit comments