Skip to main content

ChannelBuilder

Struct ChannelBuilder 

Source
pub struct ChannelBuilder<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> { /* private fields */ }
Expand description

Builder for creating tango channels with ergonomic configuration.

§Example

use tango::ChannelBuilder;

// Create channel components with the builder
let (mcache, dcache, fseq, fctl, metrics) = ChannelBuilder::<64, 64, 256>::new()
    .with_flow_control()
    .with_metrics()
    .build();

// Create producer and consumer from the components
use tango::{Producer, Consumer};
let producer = Producer::with_flow_control(&mcache, &dcache, &fseq, fctl.as_ref().unwrap());
let mut consumer = Consumer::with_flow_control(&mcache, &dcache, fctl.as_ref().unwrap(), 1);

Implementations§

Source§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

Source

pub fn new() -> Self

Create a new channel builder with default settings.

Source

pub fn initial_seq(self, seq: u64) -> Self

Set the initial sequence number (default: 1).

Source

pub fn with_flow_control(self) -> Self

Enable credit-based flow control.

Source

pub fn with_metrics(self) -> Self

Enable metrics tracking.

Source

pub fn build( self, ) -> (MCache<MCACHE_DEPTH>, DCache<CHUNK_COUNT, CHUNK_SIZE>, Fseq, Option<Fctl>, Option<Metrics>)

Build the channel components.

Returns a tuple of:

  • MCache - the metadata ring buffer
  • DCache - the data chunk storage
  • Fseq - the sequence counter
  • Option<Fctl> - flow control (if enabled)
  • Option<Metrics> - metrics (if enabled)

Trait Implementations§

Source§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Debug for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

Source§

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

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

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Default for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Freeze for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> RefUnwindSafe for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Send for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Sync for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Unpin for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> UnsafeUnpin for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

§

impl<const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> UnwindSafe for ChannelBuilder<MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>

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.