#[repr(C)]pub struct LStr { /* private fields */ }
Expand description
Internal LabVIEW string structure.
This is the recommended type when interfacing with LabVIEW as it is also the internal format so no translation is needed.
Implementations§
Source§impl LStr
impl LStr
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Access the data from the string as a mutable slice.
Use this function for modifying the data without changing the size.
If you need to change the size you must access the handle that contains
the data and access LStrHandle::set
Sourcepub fn size_with_data(data: &[u8]) -> usize
pub fn size_with_data(data: &[u8]) -> usize
Get the size of LStr given a specific data slice. Would LStr ever be padded?
Sourcepub fn to_rust_string_with_encoding(
&self,
encoding: &'static Encoding,
) -> Cow<'_, str>
pub fn to_rust_string_with_encoding( &self, encoding: &'static Encoding, ) -> Cow<'_, str>
Uses a system appropriate decoder to return a rust compatible string.
This returns a std::borrow::Cow
to avoid any allocations if the
input is already valid UTF8.
Sourcepub fn to_rust_string(&self) -> Cow<'_, str>
pub fn to_rust_string(&self) -> Cow<'_, str>
Uses a system appropriate decoder to return a rust compatible string.
This returns a std::borrow::Cow
to avoid any allocations if the
input is already valid UTF8.
§Example
use labview_interop::types::{LVStatusCode, LStrHandle};
#[no_mangle]
pub extern "C" fn string_check(mut string: LStrHandle) -> LVStatusCode {
let string_value = string.to_string();
format!("Read value: {string_value}");
LVStatusCode::SUCCESS
}
Trait Implementations§
impl LVCopy for LStr
Copyable inside a handle.