Struct LStr

Source
#[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

Source

pub fn as_slice(&self) -> &[u8]

Access the data from the string as a binary slice.

Source

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

Source

pub fn size(&self) -> usize

Get the size of this LStr instance. Would LStr ever be padded?

Source

pub fn size_with_data(data: &[u8]) -> usize

Get the size of LStr given a specific data slice. Would LStr ever be padded?

Source

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.

Source

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§

Source§

impl Debug for LStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LStr

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl LVCopy for LStr

Copyable inside a handle.

Auto Trait Implementations§

§

impl Freeze for LStr

§

impl RefUnwindSafe for LStr

§

impl Send for LStr

§

impl !Sized for LStr

§

impl Sync for LStr

§

impl Unpin for LStr

§

impl UnwindSafe for LStr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more