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.