UseCString

Trait UseCString 

Source
pub trait UseCString: SealedUseCString { }
Expand description

Helper trait that converts rusts various strings into a zero terminated c string for use with a JNI method.

This trait is implemented for: &str, String, &String, CString, CStr, *const c_char, &OsStr, OsString, &OsString, &u8, Vec,

If the String contains the equivalent of a 0 byte then the string stops at the 0 byte ignoring the rest of the string. Any non Unicode characters in OsString and its derivatives will be replaced with the Unicode replacement character by using to to_str_lossy fn. Using non utf-8 binary data in the u8 slices/Vec will not be checked for validity before being converted into a *const c_char!

  • Doing this on with any call to JNI will result in undefined behavior.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UseCString for &Cow<'_, str>

Source§

impl UseCString for &str

Source§

impl UseCString for &CString

Source§

impl UseCString for &String

Source§

impl UseCString for &Vec<u8>

Source§

impl UseCString for &CStr

Source§

impl UseCString for &OsStr

Source§

impl UseCString for &OsString

Source§

impl UseCString for &[u8]

Source§

impl UseCString for Cow<'_, str>

Source§

impl UseCString for *const i8

Source§

impl UseCString for *const u8

Source§

impl UseCString for *mut i8

Source§

impl UseCString for *mut u8

Source§

impl UseCString for ()

Source§

impl UseCString for CString

Source§

impl UseCString for String

Source§

impl UseCString for Vec<u8>

Source§

impl UseCString for OsString

Implementors§