jetstream_wireformat

Struct P9String

pub struct P9String { /* private fields */ }

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

impl P9String

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

pub fn len(&self) -> usize

pub fn is_empty(&self) -> bool

pub fn as_c_str(&self) -> &CStr

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

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

impl Clone for P9String

fn clone(&self) -> P9String

Returns a copy of the value. Read more1.0.0 ·

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

Performs copy-assignment from source. Read more

impl Debug for P9String

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

Formats the value using the given formatter. Read more

impl Hash for P9String

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

Feeds this value into the given Hasher. Read more1.3.0 ·

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

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

impl PartialEq<&str> for P9String

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

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

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

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

impl PartialEq for P9String

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

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

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

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

impl TryFrom<&OsStr> for P9String

type Error = Error

The type returned in the event of a conversion error.

fn try_from(value: &OsStr) -> Result

Performs the conversion.

impl WireFormat for P9String

fn byte_size(&self) -> u32

Returns the number of bytes necessary to fully encode self.

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

Encodes self into writer.

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

Decodes Self from reader.

impl Eq for P9String

impl StructuralPartialEq for P9String

Auto Trait Implementations

impl Freeze for P9String

impl RefUnwindSafe for P9String

impl Send for P9String

impl Sync for P9String

impl Unpin for P9String

impl UnwindSafe for P9String

Blanket Implementations

impl Any for Twhere T: 'static + ?Sized,

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more

impl AsyncWireFormatExt for Twhere T: WireFormat + Send,

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

Encodes the object asynchronously into the provided writer. Read more

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

Decodes an object asynchronously from the provided reader. Read more

impl Borrow for Twhere T: ?Sized,

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

impl BorrowMut for Twhere T: ?Sized,

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

Mutably borrows from an owned value. Read more

impl CloneToUninit for Twhere T: Clone,

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

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

impl ConvertWireFormat for Twhere T: WireFormat,

fn to_bytes(&self) -> Bytes

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

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.

fn as_bytes(&self) -> Vec

AsRef for the type. Read more

impl From for T

fn from(t: T) -> T

Returns the argument unchanged.

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

fn into(self) -> U

Calls U::from(self).

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

impl ToOwned for Twhere T: Clone,

type Owned = T

The resulting type after obtaining ownership.

fn to_owned(&self) -> T

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

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

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

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

type Error = <U as TryFrom>::Error

The type returned in the event of a conversion error.

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

Performs the conversion.