dexalt-lib 0.2.2

Dexalt Library
Documentation
//! # Raw bindings
//! This are the Raw Bindings from this Modulee for the CList.
//! You should not this for any generally action, only for experts.
//! 
//! Note
//! ----
//! This Module includes the CList full from dexalt-lib-sys.
//! 
//! <details>
//!     <summary>Includes</summary>
//!     <ol>
//!         <li><pre><code>pub struct CList</code></pre></li>
//!         <li><pre><code>pub fn CList_init</code></pre></li>
//!         <li><pre><code>pub fn CList_free</code></pre></li>
//!         <li><pre><code>pub fn CList_append</code></pre></li>
//!         <li><pre><code>pub fn CList_extend</code></pre></li>
//!         <li><pre><code>pub fn CList_push</code></pre></li>
//!         <li><pre><code>pub fn CList_remove</code></pre></li>
//!         <li><pre><code>pub fn CList_pop</code></pre></li>
//!         <li><pre><code>pub fn CList_to_array</code></pre></li>
//!         <li><pre><code>pub fn CList_to_array_new</code></pre></li>
//!         <li><pre><code>pub fn CList_size</code></pre></li>
//!         <li><pre><code>pub fn CList_len</code></pre></li>
//!         <li><pre><code>pub fn CList_lock</code></pre></li>
//!         <li><pre><code>pub fn CList_unlock</code></pre></li>
//!         <li><pre><code>pub fn CList_is_locked</code></pre></li>
//!     </ol>
//! </details>
//! 
//! **Attention**
//! This Modulee is only for experts.
//! The Includes summary show you only the generally names
//! 
//! ## use
//! 
//! ```rust
//! use dexalt_lib::clist::raw::bindings::include::*;
//! ```
pub mod include {
    pub use dexalt_lib_sys::clist::*;
}

use std::{os::raw, ptr};

/// # The Raw CList
/// 
/// The RawCList struct is the first wrapper around the C Functions.
/// He bind the C functions to a one struct/method.
/// 
/// ## Import
/// 
/// ```rust
/// use dexalt_lib::clist::raw::bindings::RawCList;
/// ```
/// 
/// ## Example
/// 
/// ```rust
/// let mut list = RawCList::new(10);
/// ```
/// 
/// **Warning**
/// All Functions are unsafe and you need following include
/// 
/// ```rust
/// use std::ptr;
/// use std::os::raw;
/// use std::ffi;
/// ```
pub struct RawCList {
    pub inner: include::CList,
}

impl RawCList {
    /// # RawCList.new
    /// 
    /// The Initial Function, set the size
    /// 
    /// ```rust
    /// let mut list = RawCList::new(10);
    /// ```
    pub fn new(size: raw::c_int) -> Self {
        let mut list = include::CList {
            data: ptr::null_mut(),
            size: 0,
            len: 0,
            locked: false,
            next: ptr::null_mut(),
        };

        unsafe {
            include::CList_init(&mut list, size);
        }

        RawCList {
            inner: list
        }
    }

    /// # RawCList.free
    /// 
    /// The Free Function, free the CList
    /// 
    /// ```rust
    /// list.free();
    /// ```
    pub fn free(&mut self) {
        unsafe {
            include::CList_free(&mut self.inner);
        }
    }

    /// # RawCList.get
    /// 
    /// The Get Function, get the CList
    /// 
    /// ```rust
    /// list.get(index);
    /// ```
    pub fn get(&mut self, index: raw::c_int) -> *mut raw::c_void {
        unsafe {
            include::CList_get(&mut self.inner, index)
        }
    }

    /// # RawCList.append
    /// 
    /// The Append Function, append the CList
    /// 
    /// ```rust
    /// list.append(data);
    /// ```
    pub fn append(&mut self, data: *mut raw::c_void) {
        unsafe {
            include::CList_append(&mut self.inner, data);
        }
    }

    /// # RawCList.extend
    /// 
    /// The Extend Function, extend the CList
    /// 
    /// ```rust
    /// list.extend(list);
    /// ```
    pub fn extend(&mut self, list: *mut include::CList) {
        unsafe {
            include::CList_extend(&mut self.inner, list);
        }
    }

    /// # RawCList.push
    /// 
    /// The Push Function, push the CList
    /// 
    /// ```rust
    /// list.push(array);
    /// ```
    pub fn push(&mut self, array: *mut raw::c_void) {
        unsafe {
            include::CList_push(&mut self.inner, array);
        }
    }

    /// # RawCList.remove
    /// 
    /// The Remove Function, remove the CList
    /// 
    /// ```rust
    /// list.remove(data);
    /// ```
    pub fn remove(&mut self, data: *mut raw::c_void) {
        unsafe {
            include::CList_remove(&mut self.inner, data);
        }
    }

    /// # RawCList.pop
    /// 
    /// The Pop Function, pop the CList
    /// 
    /// ```rust
    /// list.pop(index);
    /// ```
    pub fn pop(&mut self, index: raw::c_int) {
        unsafe {
            include::CList_pop(&mut self.inner, index);
        }
    }

    /// # RawCList.to_array
    /// 
    /// The To Array Function, to array the CList
    /// 
    /// ```rust
    /// list.to_array(array);
    /// ```
    pub fn to_array(&mut self, array: *mut *mut raw::c_void) -> *mut raw::c_void {
        unsafe {
            include::CList_to_array(&mut self.inner, array)
        }
    }

    /// # RawCList.to_array_new
    /// 
    /// The To Array New Function, to array new the CList
    /// 
    /// ```rust
    /// list.to_array_new();
    /// ```
    pub fn to_array_new(&mut self) -> *mut raw::c_void {
        unsafe {
            include::CList_to_array_new(&mut self.inner)
        }
    }

    /// # RawCList.size
    /// 
    /// The Size Function, size the CList
    /// 
    /// ```rust
    /// list.size();
    /// ```
    pub fn size(&mut self) -> raw::c_int {
        unsafe {
            include::CList_size(&mut self.inner)
        }
    }

    /// # RawCList.len
    /// 
    /// The Len Function, len the CList
    /// 
    /// ```rust
    /// list.len();
    /// ```
    pub fn len(&mut self) -> raw::c_int {
        unsafe {
            include::CList_len(&mut self.inner)
        }
    }

    /// # RawCList.lock
    /// 
    /// The Lock Function, lock the CList
    /// 
    /// ```rust
    /// list.lock();
    /// ```
    pub fn lock(&mut self) {
        unsafe {
            include::CList_lock(&mut self.inner)
        }
    }

    /// # RawCList.unlock
    /// 
    /// The Unlock Function, unlock the CList
    /// 
    /// ```rust
    /// list.unlock();
    /// ```
    pub fn unlock(&mut self) {
        unsafe {
            include::CList_unlock(&mut self.inner)
        }
    }

    /// # RawCList.is_locked
    /// 
    /// The Is Locked Function, is locked the CList
    /// 
    /// ```rust
    /// list.is_locked();
    /// ```
    pub fn is_locked(&mut self) -> bool {
        unsafe {
            include::CList_is_locked(&mut self.inner)
        }
    }

    /// # RawCList.get_data
    /// 
    /// The Get Data Function, get data the CList
    /// 
    /// ```rust
    /// list.get_data();
    /// ```
    pub fn get_data(&self) -> *mut raw::c_void {
        self.inner.data
    }

    /// # RawCList.get_next
    /// 
    /// The Get Next Function, get the next
    /// 
    /// ```rust
    /// list.get_next();
    /// ```
    pub fn get_next(&self) -> *mut include::CList {
        self.inner.next
    }

}