Skip to main content

TelemetryCollector

Struct TelemetryCollector 

Source
pub struct TelemetryCollector<T: Transcendental, const BUF_SIZE: usize, const QUEUE_CAP: usize> { /* private fields */ }
Expand description

Non-real-time consumer of telemetry frames from a shared SpscQueue.

Runs on the control thread (or any non-RT context). Drains available frames from the ring buffer and delivers them to a user-supplied callback.

§Example

use std::sync::Arc;
use rill_core::queues::spsc::SpscQueue;
use rill_core::queues::TelemetryBlock;
use rill_telemetry::collector::TelemetryCollector;

let queue = Arc::new(SpscQueue::<TelemetryBlock<f32, 64>, 8>::new());
let mut collector = TelemetryCollector::new(queue, |frame| {
    println!("peak={} rms={} dc={}", frame.peak, frame.rms, frame.dc_offset);
});
collector.poll();  // drain available frames

Implementations§

Source§

impl<T: Transcendental, const BUF_SIZE: usize, const QUEUE_CAP: usize> TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

Source

pub fn new( queue: Arc<SpscQueue<TelemetryBlock<T, BUF_SIZE>, QUEUE_CAP>>, callback: impl FnMut(TelemetryBlock<T, BUF_SIZE>) + 'static, ) -> Self

Create a new collector backed by the shared ring buffer.

The callback is invoked for every frame drained from the queue.

Source

pub fn poll(&mut self) -> usize

Drain all available telemetry frames from the ring buffer.

Returns the number of frames processed.

Source

pub fn poll_n(&mut self, max: usize) -> usize

Drain at most max frames from the ring buffer.

Useful when you want to bound processing time per tick.

Source

pub fn available(&self) -> usize

Number of frames currently available in the ring buffer (approximate).

Source

pub fn into_queue( self, ) -> Arc<SpscQueue<TelemetryBlock<T, BUF_SIZE>, QUEUE_CAP>>

Consume the collector and return the underlying queue Arc.

Auto Trait Implementations§

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> Freeze for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> !RefUnwindSafe for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> !Send for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> !Sync for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> Unpin for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> UnsafeUnpin for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

§

impl<T, const BUF_SIZE: usize, const QUEUE_CAP: usize> !UnwindSafe for TelemetryCollector<T, BUF_SIZE, QUEUE_CAP>

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
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.