[][src]Struct wrapgen::WrapperType

pub struct WrapperType<'a> {
    pub original: &'a str,
    pub renamed: &'a str,
    // some fields omitted
}

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 strrenamed: &'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]

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]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.