Output

Enum Output 

Source
pub enum Output {
    File(PathBuf),
    Tcp(String),
    Channel(Sender<Snapshot>),
}
Expand description

Output destination for snapshots.

Configure where the instrumentor should emit snapshots.

Variants§

§

File(PathBuf)

Write snapshots to a JSON file.

The file is overwritten with each snapshot.

§

Tcp(String)

Send snapshots to a TCP server.

Each snapshot is sent as a newline-delimited JSON message.

§

Channel(Sender<Snapshot>)

Send snapshots through a channel.

Use Output::channel() to create this variant and get the receiver.

Implementations§

Source§

impl Output

Source

pub fn file(path: impl Into<PathBuf>) -> Self

Create a file output.

§Example
use buswatch_sdk::Output;

let output = Output::file("metrics.json");
Source

pub fn tcp(addr: impl Into<String>) -> Self

Create a TCP output.

§Example
use buswatch_sdk::Output;

let output = Output::tcp("localhost:9090");
Source

pub fn channel(buffer: usize) -> (Self, Receiver<Snapshot>)

Create a channel output and return both the output and receiver.

This is useful for integrating with your own snapshot handling.

§Example
use buswatch_sdk::Output;

let (output, mut rx) = Output::channel(16);

// Later, receive snapshots
// while let Some(snapshot) = rx.recv().await {
//     println!("Got snapshot with {} modules", snapshot.len());
// }

Trait Implementations§

Source§

impl Debug for Output

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Output

§

impl RefUnwindSafe for Output

§

impl Send for Output

§

impl Sync for Output

§

impl Unpin for Output

§

impl UnwindSafe for Output

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.