Skip to main content

C3String

Struct C3String 

Source
pub struct C3String { /* private fields */ }
Expand description

A standard C3 String. It holds a constant pointer to a c_void and an usize holding the length of the string.

Implementations§

Source§

impl C3String

Source

pub fn ptr(&self) -> *const c_void

Source

pub fn len(&self) -> usize

Source

pub fn into_c3_string<P>(value: P) -> Self
where P: Into<String>,

Converts a given String or slice into a C3String.

Example:

c3ne_types::C3String::into_c3_string("Hello, World!");
Source

pub fn str_from_c3_string(&self) -> Result<&'static str, Box<dyn Error>>

Converts a given C3String into a string slice.

Example:

let c3_string = c3ne_types::C3String::into_c3_string("Hello, World!");
assert!("Hello, World!", c3_string.str_from_c3_string().unwrap());
Source

pub fn into_c3_zstring<P>(value: P) -> C3ZString
where P: Into<String>,

Converts a given String or slice into a C3ZString.

Example:

c3ne_types::C3String::into_c3_zstring("Hello, World!");
Source

pub fn str_from_c3_zstring( ptr: C3ZString, ) -> Result<&'static str, Box<dyn Error>>

Converts a given C3ZString into a string slice.

Example:

let c3_zstring = c3ne_types::C3String::into_c3_zstring("Hello, World!");
assert!("Hello, World!", c3ne_types::CString::str_from_c3_zstring(c3_zstring));
Source

pub fn into_c3_wstring<P>(value: P) -> C3WString
where P: Into<String>,

Converts a given String or slice into a C3WString.

Example:

c3ne_types::C3String::into_c3_wstring("Hello, World!");
Source

pub fn str_from_c3_wstring( ptr: C3WString, ) -> Result<&'static str, Box<dyn Error>>

Converts a given C3WString into a string slice.

Example:

let c3_wstring = c3ne_types::C3String::into_c3_wstring("Hello, World!");
assert!("Hello, World!", c3ne_types::CString::str_from_c3_wstring(c3_wstring));
Source

pub fn into_c3_dstring<P>(value: P) -> C3DString
where P: Into<String>,

Converts a given String or slice into a C3DString.

Example:

c3ne_types::C3String::into_c3_dstring("Hello, World!");
Source

pub fn str_from_c3_dstring( ptr: C3DString, ) -> Result<&'static str, Box<dyn Error>>

Converts a given C3DString into a string slice.

Example:

let c3_dstring = c3ne_types::C3String::into_c3_dstring("Hello, World!");
assert!("Hello, World!", c3ne_types::CString::str_from_c3_dstring(c3_dstring));

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.