pub struct ObsString { /* private fields */ }
Expand description
String wrapper for OBS function calls.
ObsString
provides safe interaction with OBS C API functions that require
C-style strings. It wraps CString
internally with convenient helper functions
for converting between Rust strings and C-compatible strings.
§Safety
- Any NUL byte in input strings is stripped during conversion to prevent panicking
- Memory is properly managed to prevent use-after-free and memory leaks
- Automatically handles conversion between Rust’s UTF-8 strings and C’s NUL-terminated strings
§Examples
use libobs_wrapper::utils::ObsString;
// Create an ObsString from a Rust string
let obs_string = ObsString::new("Hello, OBS!");
// Use in OBS API calls
unsafe {
let ptr = obs_string.as_ptr();
// Pass ptr.0 to OBS functions
}
Implementations§
Source§impl ObsString
impl ObsString
Sourcepub fn new<S: AsRef<str>>(s: S) -> Self
pub fn new<S: AsRef<str>>(s: S) -> Self
Creates a new ObsString
from a string slice.
Any NUL bytes in the input are automatically stripped to prevent panicking when converting to a C string.
§Examples
use libobs_wrapper::utils::ObsString;
let obs_string = ObsString::new("source_name");
Sourcepub fn as_ptr(&self) -> Sendable<*const c_char>
pub fn as_ptr(&self) -> Sendable<*const c_char>
Returns a pointer to the underlying C string along with sendable wrapper.
The returned pointer is suitable for passing to OBS C API functions.
§Examples
use libobs_wrapper::utils::ObsString;
let obs_string = ObsString::new("source_name");
let ptr = obs_string.as_ptr();
// Use ptr.0 in OBS API calls
Trait Implementations§
Source§impl Into<ObsString> for ObsAudioEncoderType
impl Into<ObsString> for ObsAudioEncoderType
Source§impl Into<ObsString> for ObsVideoEncoderType
impl Into<ObsString> for ObsVideoEncoderType
Source§impl Ord for ObsString
impl Ord for ObsString
Source§impl PartialOrd for ObsString
impl PartialOrd for ObsString
impl Eq for ObsString
impl StructuralPartialEq for ObsString
Auto Trait Implementations§
impl Freeze for ObsString
impl RefUnwindSafe for ObsString
impl Send for ObsString
impl Sync for ObsString
impl Unpin for ObsString
impl UnwindSafe for ObsString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.