pub struct ImString(/* private fields */);
Expand description
A UTF-8 encoded, growable, implicitly nul-terminated string.
Implementations§
Source§impl ImString
impl ImString
Sourcepub fn new<T: Into<String>>(value: T) -> ImString
pub fn new<T: Into<String>>(value: T) -> ImString
Creates a new ImString
from an existing string.
Sourcepub fn with_capacity(capacity: usize) -> ImString
pub fn with_capacity(capacity: usize) -> ImString
Creates a new empty ImString
with a particular capacity
Sourcepub unsafe fn from_utf8_unchecked(v: Vec<u8>) -> ImString
pub unsafe fn from_utf8_unchecked(v: Vec<u8>) -> ImString
Converts a vector of bytes to a ImString
without checking that the string contains valid
UTF-8
§Safety
It is up to the caller to guarantee the vector contains valid UTF-8 and no null terminator.
Sourcepub unsafe fn from_utf8_with_nul_unchecked(v: Vec<u8>) -> ImString
pub unsafe fn from_utf8_with_nul_unchecked(v: Vec<u8>) -> ImString
Converts a vector of bytes to a ImString
without checking that the string contains valid
UTF-8
§Safety
It is up to the caller to guarantee the vector contains valid UTF-8 and a null terminator.
Sourcepub fn push_str(&mut self, string: &str)
pub fn push_str(&mut self, string: &str)
Appends a given string slice to the end of this ImString
Sourcepub fn capacity_with_nul(&self) -> usize
pub fn capacity_with_nul(&self) -> usize
Returns the capacity of this ImString
in bytes, including the implicit null byte
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Ensures that the capacity of this ImString
is at least additional
bytes larger than the
current length.
The capacity may be increased by more than additional
bytes.
Sourcepub fn reserve_exact(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
Ensures that the capacity of this ImString
is at least additional
bytes larger than the
current length
Sourcepub fn as_mut_ptr(&mut self) -> *mut c_char
pub fn as_mut_ptr(&mut self) -> *mut c_char
Returns a raw mutable pointer to the underlying buffer.
If the underlying data is modified, refresh_len
must be called afterwards.
Sourcepub unsafe fn refresh_len(&mut self)
pub unsafe fn refresh_len(&mut self)
Updates the underlying buffer length based on the current contents.
This function must be called if the underlying data is modified via a pointer
obtained by as_mut_ptr
.
§Safety
It is up to the caller to guarantee the this ImString contains valid UTF-8 and a null terminator.