[−][src]Struct wrapgen::WrapperType
The representation of a pointer type to wrap.
If you wrap a pointer type *mut T
, it will be represtented
as Wrapper<T>
where Wrapper
is defined as the following
zero-cost abstraction:
pub struct Wrapper<T> { ptr: *mut T } impl<T> Wrapper<T> { pub fn from_ptr(ptr: *mut T) -> Self { Self { ptr } } pub fn get_ptr(&self) -> *mut T { self.ptr } }
WrapGen can create methods to safely access fields present on *mut T
.
Example
WrapperType::new("inode", "Inode") .with_field("i_sb", "*mut super_block") .with_field_writeonly("i_ino", "cty::c_int")
Fields
original: &'a str
renamed: &'a str
Implementations
impl<'a> WrapperType<'a>
[src]
pub fn new(original: &'a str, renamed: &'a str) -> Self
[src]
Create a new wrapper for type *mut original
pub fn with_field(self, field_name: &'a str, field_type: &'a str) -> Self
[src]
Add a field present on *mut original
that has a getter and setter
pub fn with_field_readonly(
self,
field_name: &'a str,
field_type: &'a str
) -> Self
[src]
self,
field_name: &'a str,
field_type: &'a str
) -> Self
Add a field present on *mut original
that will only be read
pub fn with_field_writeonly(
self,
field_name: &'a str,
field_type: &'a str
) -> Self
[src]
self,
field_name: &'a str,
field_type: &'a str
) -> Self
Add a field present on *mut original
that will only be written to
pub fn generate(&self) -> String
[src]
Generate the implementation of the wrapper
Trait Implementations
impl<'a> Clone for WrapperType<'a>
[src]
fn clone(&self) -> WrapperType<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for WrapperType<'a>
impl<'a> Send for WrapperType<'a>
impl<'a> Sync for WrapperType<'a>
impl<'a> Unpin for WrapperType<'a>
impl<'a> UnwindSafe for WrapperType<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,