cluFlock/
element.rs

1
2//! FlockElement is required to implement additional Flock locks.
3//!
4
5/// FlockElement is required to implement additional Flock locks.
6pub trait FlockElement {
7	/// Unix: RawFd,
8	/// Win: RawHandle
9	type FilePtr;
10	
11	fn as_file_ptr(&self) -> Self::FilePtr;
12}
13
14impl<'a, 'l, T: 'l> FlockElement for &'a T where T: FlockElement {
15	type FilePtr = T::FilePtr;
16	
17	#[inline(always)]
18	fn as_file_ptr(&self) -> Self::FilePtr {
19		T::as_file_ptr(self)
20	}
21}
22
23impl<T> FlockElement for Box<T> where T: FlockElement {
24	type FilePtr = T::FilePtr;
25	
26	#[inline(always)]
27	fn as_file_ptr(&self) -> Self::FilePtr {
28		T::as_file_ptr(self)
29	}
30}
31
32impl<'a, 'l, T: 'l> FlockElement for &'a mut T where T: FlockElement {
33	type FilePtr = T::FilePtr;
34	
35	#[inline(always)]
36	fn as_file_ptr(&self) -> Self::FilePtr {
37		T::as_file_ptr(self)
38	}
39}