Struct libuv::buf::Buf

source ·
pub struct Buf { /* private fields */ }
Expand description

Buffer data type.

Implementations§

source§

impl Buf

source

pub fn new(s: &str) -> Result<Buf, Box<dyn Error>>

Create a new Buf with the given string

source

pub fn new_from_bytes(bytes: &[u8]) -> Result<Buf, Box<dyn Error>>

Create a new Buf from the given byte slice

source

pub fn with_capacity(size: usize) -> Result<Buf>

Create a Buf with the given capacity - the memory is not initialized

source

pub fn new_from(other: &impl BufTrait, size: Option<usize>) -> Result<Self>

Create a duplicate of this Buf - if the optional size parameter is None, the new Buf will have the same size as the existing Buf. Otherwise, the new Buf will have the specified size and data up to that size, or the size of the original buf, whichever is lower, will be copied.

source

pub fn is_allocated(&self) -> bool

Returns true if the internal buffer is initialized

source

pub fn resize(&mut self, size: usize) -> Result<()>

Resizes the internal buffer

source

pub fn copy_from(&mut self, other: &impl BufTrait) -> Result<()>

Copies the data from a Buf to this one.

source

pub fn dealloc(&mut self)

Deallocate the internal buffer, but leave the Buf intact.

source

pub fn destroy(&mut self)

Deallocates the internal buffer and the Buf

Trait Implementations§

source§

impl BufTrait for Buf

source§

impl Clone for Buf

source§

fn clone(&self) -> Buf

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 From<Buf> for ReadonlyBuf

source§

fn from(buf: Buf) -> ReadonlyBuf

Converts to this type from the input type.
source§

impl TryFrom<&str> for Buf

§

type Error = Box<dyn Error>

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

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

Performs the conversion.
source§

impl Copy for Buf

Auto Trait Implementations§

§

impl RefUnwindSafe for Buf

§

impl !Send for Buf

§

impl !Sync for Buf

§

impl Unpin for Buf

§

impl UnwindSafe for Buf

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

§

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

§

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.