Skip to main content

BufferPoolBuilder

Struct BufferPoolBuilder 

Source
pub struct BufferPoolBuilder<V: Default + Clone> { /* private fields */ }
Expand description

A builder interface for creating a new BufferPool.

Implementations§

Source§

impl<V: Default + Clone> BufferPoolBuilder<V>

Source

pub fn new() -> BufferPoolBuilder<V>

Examples found in repository?
examples/sum-vector.rs (line 4)
3fn main() {
4    let mut pool: BufferPool<usize> = BufferPoolBuilder::new()
5        .with_buffer_size(1024)
6        .with_capacity(100)
7        .build();
8    let mut buffer = pool.get_cleared_space().unwrap();
9    for (index, value) in buffer.as_mut().iter_mut().enumerate() {
10        *value = index;
11    }
12    let sum: usize = buffer.as_ref().iter().sum();
13    println!("Sum {}", sum);
14}
Source

pub fn with_capacity(self, capacity: usize) -> BufferPoolBuilder<V>

Set the capacity of the buffer pool - the max number of internal buffers.

Examples found in repository?
examples/sum-vector.rs (line 6)
3fn main() {
4    let mut pool: BufferPool<usize> = BufferPoolBuilder::new()
5        .with_buffer_size(1024)
6        .with_capacity(100)
7        .build();
8    let mut buffer = pool.get_cleared_space().unwrap();
9    for (index, value) in buffer.as_mut().iter_mut().enumerate() {
10        *value = index;
11    }
12    let sum: usize = buffer.as_ref().iter().sum();
13    println!("Sum {}", sum);
14}
Source

pub fn with_buffer_size(self, buffer_size: usize) -> BufferPoolBuilder<V>

Set the buffer size / length of the internal buffers.

Examples found in repository?
examples/sum-vector.rs (line 5)
3fn main() {
4    let mut pool: BufferPool<usize> = BufferPoolBuilder::new()
5        .with_buffer_size(1024)
6        .with_capacity(100)
7        .build();
8    let mut buffer = pool.get_cleared_space().unwrap();
9    for (index, value) in buffer.as_mut().iter_mut().enumerate() {
10        *value = index;
11    }
12    let sum: usize = buffer.as_ref().iter().sum();
13    println!("Sum {}", sum);
14}
Source

pub fn build(self) -> BufferPool<V>

Examples found in repository?
examples/sum-vector.rs (line 7)
3fn main() {
4    let mut pool: BufferPool<usize> = BufferPoolBuilder::new()
5        .with_buffer_size(1024)
6        .with_capacity(100)
7        .build();
8    let mut buffer = pool.get_cleared_space().unwrap();
9    for (index, value) in buffer.as_mut().iter_mut().enumerate() {
10        *value = index;
11    }
12    let sum: usize = buffer.as_ref().iter().sum();
13    println!("Sum {}", sum);
14}

Trait Implementations§

Source§

impl<V: Clone + Default> Default for BufferPoolBuilder<V>

Source§

fn default() -> BufferPoolBuilder<V>

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

Auto Trait Implementations§

§

impl<V> Freeze for BufferPoolBuilder<V>

§

impl<V> RefUnwindSafe for BufferPoolBuilder<V>
where V: RefUnwindSafe,

§

impl<V> Send for BufferPoolBuilder<V>
where V: Send,

§

impl<V> Sync for BufferPoolBuilder<V>
where V: Sync,

§

impl<V> Unpin for BufferPoolBuilder<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for BufferPoolBuilder<V>

§

impl<V> UnwindSafe for BufferPoolBuilder<V>
where V: UnwindSafe,

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

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.