Struct c_ffi::args::Args [−][src]
Wrapper over C-style arguments
Example:
On most targets you can supply own C-style main function.
One of the benefits is that it is no longer necessary to rely on allocating std::env::Args
#![no_main] #[no_mangle] pub unsafe extern fn main(argc: std::os::raw::c_int, argv: *const *const u8) -> std::os::raw::c_int { let args = c_ffi::Args::new(argc as isize, argv).expect("To get function arguments"); 0 }
Implementations
impl Args[src]
pub unsafe fn new(
argc: isize,
argv: *const *const u8
) -> Result<Self, (usize, Utf8Error)>[src]
argc: isize,
argv: *const *const u8
) -> Result<Self, (usize, Utf8Error)>
Creates new instance, but verifies that each string inside are UTF-8.
On error returns pair: (string index, Utf8Error)
The function is safe as long as you pass C style main function arguments.
pub unsafe fn new_unchecked(argc: isize, argv: *const *const u8) -> Self[src]
Unchecked version of Args::new
Do it on your own risk
pub fn as_slice(&self) -> &[*const u8][src]
Returns slice of raw C strings
pub unsafe fn get_str_by_index(&self, index: usize) -> &str[src]
Retrieves string by index.
No checks, 100% unsafe.
Trait Implementations
impl Clone for Args[src]
fn clone(&self) -> Args[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for Args[src]
impl<'a> IntoIterator for &'a Args[src]
Auto Trait Implementations
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,
pub 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, 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.
pub 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>,