Struct wstp::LinkStr

source ·
pub struct LinkStr<'link, T: LinkStrType + ?Sized = str> { /* private fields */ }
Expand description

String borrowed from a Link.

LinkStr is returned from:

When LinkStr is dropped, the string is deallocated by the Link.

Example

use wstp::{Link, LinkStr};

let mut link = Link::new_loopback().unwrap();

link.put_str("hello world").unwrap();

// Read a string from the link
let string: LinkStr = link.get_string_ref().unwrap();

// Get a `&str` from the `LinkStr`
assert_eq!(string.as_str(), "hello world");

Implementations§

source§

impl<'link, T: LinkStrType + ?Sized> LinkStr<'link, T>

source

pub fn get<'this>(&'this self) -> &'this T

Get the string contained by this LinkStr.

source§

impl<'link> LinkStr<'link, str>

source

pub fn as_str<'s>(&'s self) -> &'s str

Get the UTF-8 string data.

source

pub fn to_str<'s>(&'s self) -> &'s str

👎Deprecated: Use LinkStr::as_str() instead

Get the UTF-8 string data.

Trait Implementations§

source§

impl<'link, T: LinkStrType + Debug + ?Sized> Debug for LinkStr<'link, T>

source§

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

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

impl<'link, T: ?Sized + LinkStrType> Drop for LinkStr<'link, T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'link, T: ?Sized> RefUnwindSafe for LinkStr<'link, T>
where <T as LinkStrType>::Element: RefUnwindSafe,

§

impl<'link, T = str> !Send for LinkStr<'link, T>

§

impl<'link, T = str> !Sync for LinkStr<'link, T>

§

impl<'link, T: ?Sized> Unpin for LinkStr<'link, T>

§

impl<'link, T: ?Sized> UnwindSafe for LinkStr<'link, T>
where <T as LinkStrType>::Element: RefUnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.