Skip to main content

StringBuffer

Struct StringBuffer 

Source
pub struct StringBuffer<'a> { /* private fields */ }
Expand description

A buffered String suitable for sending across as a message

Implementations§

Source§

impl<'a> StringBuffer<'a>

Source

pub fn new() -> Self

Create a new StringBuffer with no backing. This will get resized as soon as data is written to it.

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new StringBuffer with enough space to hold usize characters

Source

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

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Source

pub fn as_str(&self) -> Result<&str, Utf8Error>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear(&mut self)

Clear the contents of this String and set the length to 0

Source

pub fn to_str(&self) -> &str

Source

pub unsafe fn from_memory_message(mem: &'a MemoryMessage) -> Self

§Safety

This can turn any MemoryMessage into a StringBuffer, so ensure that this function is only called when the contents are a StringBuffer

Source

pub unsafe fn from_memory_message_mut(mem: &'a mut MemoryMessage) -> Self

§Safety

This can turn any MemoryMessage into a StringBuffer, so ensure that this function is only called when the contents are a StringBuffer

Source

pub fn lend_mut(&mut self, connection: CID, id: u32) -> Result<Result, Error>

Perform a mutable lend of this String to the server.

Source

pub fn lend(&self, connection: CID, id: u32) -> Result<Result, Error>

Source

pub fn send(self, connection: CID, id: u32) -> Result<Result, Error>

Trait Implementations§

Source§

impl<'a> AsRef<str> for StringBuffer<'a>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Debug for StringBuffer<'a>

Source§

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

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

impl<'a> Default for StringBuffer<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> Display for StringBuffer<'a>

Source§

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

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

impl<'a> Drop for StringBuffer<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> FromStr for StringBuffer<'a>

Source§

type Err = &'static str

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<StringBuffer<'a>, &'static str>

Parses a string s to return a value of this type. Read more
Source§

impl<'a> PartialEq for StringBuffer<'a>

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<'a> Write for StringBuffer<'a>

Source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl<'a> Eq for StringBuffer<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for StringBuffer<'a>

§

impl<'a> RefUnwindSafe for StringBuffer<'a>

§

impl<'a> Send for StringBuffer<'a>

§

impl<'a> Sync for StringBuffer<'a>

§

impl<'a> Unpin for StringBuffer<'a>

§

impl<'a> !UnwindSafe for StringBuffer<'a>

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> ToString for T
where T: Display + ?Sized,

Source§

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.