Struct rcstring::CString [] [src]

pub struct CString<'a> {
    // some fields omitted
}

Type representing a C-compatible string.

Methods

impl<'a> CString<'a>

fn new(s: &'a str) -> Result<CString<'a>, Error>

Constructs a new CString from a string slice

The caller MUST ensure that there is a trailing NULL to terminate the string. To make this easier, the cstr! macro is provided.

CStrings MUST NOT have any non-ASCII characters, even extended ASCII characters aren't allowed.

Examples

use rcstring::CString;

let cs = CString::new("foo\0").unwrap();

unsafe fn from_raw(ptr: *const c_char) -> Result<CString<'a>, Error>

Converts an exising raw pointer to a string and converts it to a CString with a length determined by an internal strlen implementation.

unsafe fn into_raw(&self) -> *const c_char

Returns a mutable pointer to a CString for use in functions taking a classic C string

fn len(&self) -> usize

Returns length of string, including trailing NULL

Trait Implementations

impl<'a> Eq for CString<'a>

impl<'a> PartialEq for CString<'a>

fn eq(&self, other: &CString) -> bool

fn ne(&self, other: &CString) -> bool

impl<'a> PartialOrd for CString<'a>

fn partial_cmp(&self, other: &CString) -> Option<Ordering>

fn le(&self, other: &CString) -> bool

fn ge(&self, other: &CString) -> bool

fn lt(&self, other: &CString) -> bool

fn gt(&self, other: &CString) -> bool

impl<'a> Ord for CString<'a>

fn cmp(&self, other: &CString) -> Ordering