Struct open62541::ua::String

source ·
pub struct String(/* private fields */);
Expand description

Wrapper for UA_String from open62541_sys.

This owns the wrapped data. When the wrapper is dropped, the inner value is cleaned up with UA_clear() to release dynamically allocated memory held by the value.

Implementations§

source§

impl String

source

pub fn new(s: &str) -> Result<Self, Error>

Creates string from string slice.

§Errors

The string must not contain any NUL bytes.

source

pub fn is_invalid(&self) -> bool

Checks if string is invalid.

The invalid state is defined by OPC UA. It is a third state which is distinct from empty and regular (non-empty) strings.

source

pub fn is_empty(&self) -> bool

Checks if string is empty.

source

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

👎Deprecated: use Self::as_bytes() instead
source

pub fn as_bytes(&self) -> Option<&[u8]>

Returns string contents as byte slice.

This may return None when the string itself is invalid (as defined by OPC UA).

source

pub fn as_str(&self) -> Option<&str>

Returns string contents as string slice.

This may return None when the string itself is invalid (as defined by OPC UA) or when it is not valid Unicode (UTF-8).

Trait Implementations§

source§

impl Clone for String

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl DataType for String

source§

type Inner = UA_String

Inner type. Read more
source§

fn data_type() -> *const UA_DataType

Gets open62541 data type record. Read more
source§

unsafe fn from_raw(src: Self::Inner) -> Self

Creates wrapper by taking ownership of value. Read more
source§

fn into_raw(self) -> Self::Inner

Gives up ownership and returns value. Read more
source§

fn type_name() -> &'static str

Gets data type name.
source§

fn init() -> Self

Creates wrapper initialized with defaults. Read more
source§

fn raw_ref(src: &Self::Inner) -> &Self

Creates wrapper reference from value.
source§

fn raw_mut(src: &mut Self::Inner) -> &mut Self

Creates mutable wrapper reference from value.
source§

fn clone_raw(src: &Self::Inner) -> Self

Creates wrapper by cloning value from src. Read more
source§

fn clone_into_raw(&self, dst: &mut Self::Inner)

Clones value into dst. Read more
source§

fn move_into_raw(self, dst: &mut Self::Inner)

Moves value into dst, giving up ownership. Read more
source§

fn leak_into_raw(self) -> *mut Self::Inner

Leaks wrapped value onto the heap. Read more
source§

unsafe fn to_raw_copy(this: &Self) -> Self::Inner

Creates copy without giving up ownership. Read more
source§

unsafe fn as_ref(&self) -> &Self::Inner

Returns shared reference to value. Read more
source§

unsafe fn as_mut(&mut self) -> &mut Self::Inner

Returns exclusive reference to value. Read more
source§

unsafe fn as_ptr(&self) -> *const Self::Inner

Returns const pointer to value. Read more
source§

unsafe fn as_mut_ptr(&mut self) -> *mut Self::Inner

Returns mutable pointer to value. Read more
source§

fn print(this: &Self) -> Option<String>

Prints value to string. Read more
source§

fn order(this: &Self, other: &Self) -> UA_Order

Compares value to other. Read more
source§

impl Debug for String

source§

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

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

impl Display for String

source§

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

Creates string from String value.

§Examples
use open62541::{ua, DataType as _};

let node_id = ua::String::init();
let str = node_id.to_string();

assert_eq!(str, "");
source§

impl Drop for String

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Ord for String

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for String

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 PartialOrd for String

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for String

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for String

source§

impl Send for String

source§

impl Sync for String

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.