P9String

Struct P9String 

Source
pub struct P9String { /* private fields */ }
Expand description

A 9P protocol string.

The string is always valid UTF-8 and 65535 bytes or less (enforced by P9String::new()).

It is represented as a C string with a terminating 0 (NUL) character to allow it to be passed directly to libc functions.

Implementations§

Source§

impl P9String

Source

pub fn new(string_bytes: impl Into<Vec<u8>>) -> Result<Self>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_c_str(&self) -> &CStr

Source

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

Source

pub fn as_ptr(&self) -> *const c_char

Returns a raw pointer to the string’s storage.

The string bytes are always followed by a NUL terminator (‘\0’), so the pointer can be passed directly to libc functions that expect a C string.

Trait Implementations§

Source§

impl Clone for P9String

Source§

fn clone(&self) -> P9String

Returns a duplicate 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 Debug for P9String

Source§

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

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

impl Hash for P9String

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<&str> for P9String

Source§

fn eq(&self, other: &&str) -> 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 PartialEq for P9String

Source§

fn eq(&self, other: &P9String) -> 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 TryFrom<&OsStr> for P9String

Source§

type Error = Error

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

fn try_from(value: &OsStr) -> Result<Self>

Performs the conversion.
Source§

impl WireFormat for P9String

Source§

fn byte_size(&self) -> u32

Returns the number of bytes necessary to fully encode self.
Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Encodes self into writer.
Source§

fn decode<R: Read>(reader: &mut R) -> Result<Self>

Decodes Self from reader.
Source§

impl Eq for P9String

Source§

impl StructuralPartialEq for P9String

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> AsyncWireFormatExt for T
where T: WireFormat + Send,

Source§

fn encode_async<W>(self, writer: W) -> impl Future<Output = Result<()>>
where Self: Sync + Sized, W: AsyncWrite + Unpin + Send,

Encodes the object asynchronously into the provided writer. Read more
Source§

fn decode_async<R>(reader: R) -> impl Future<Output = Result<Self>> + Send
where Self: Sync + Sized, R: AsyncRead + Unpin + Send,

Decodes an object asynchronously from the provided reader. 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, dest: *mut u8)

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

impl<T> ConvertWireFormat for T
where T: WireFormat,

Source§

fn to_bytes(&self) -> Bytes

Converts the type to bytes. Returns a Bytes object containing the encoded bytes.

Source§

fn from_bytes(buf: &Bytes) -> Result<T, Error>

Converts bytes to the type. Returns a Result containing the decoded type or an std::io::Error if decoding fails.

Source§

fn as_bytes(&self) -> Vec<u8>

AsRef<u8> for the type. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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, 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.
§

impl<T> ErasedDestructor for T
where T: 'static,