Skip to main content

FnSink

Struct FnSink 

Source
pub struct FnSink<F>(pub F);
Expand description

A closure as a Sink.

use fit_encoder::{FnSink, Sink};

let mut seen = 0;
let mut sink = FnSink(|bytes: &[u8]| -> Result<(), ()> {
    seen += bytes.len();
    Ok(())
});
sink.write(b"abc").unwrap();
drop(sink);
assert_eq!(seen, 3);

Tuple Fields§

§0: F

Trait Implementations§

Source§

impl<F> Debug for FnSink<F>

Source§

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

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

impl<F: FnMut(&[u8]) -> Result<(), E>, E> Sink for FnSink<F>

Source§

type Error = E

Why a write failed.
Source§

fn write(&mut self, bytes: &[u8]) -> Result<(), E>

Writes all of bytes, or fails. Read more
Source§

fn begin(&mut self, _file_size: u32) -> Result<(), Self::Error>

The whole file’s length, for a sink that announces it, such as a transfer over a radio link. Only write() knows it in advance and calls this, once, before the first byte; OnePass never does. Read more

Auto Trait Implementations§

§

impl<F> Forget for FnSink<F>

§

impl<F> Freeze for FnSink<F>
where F: Freeze,

§

impl<F> Move for FnSink<F>

§

impl<F> RefUnwindSafe for FnSink<F>
where F: RefUnwindSafe,

§

impl<F> Send for FnSink<F>
where F: Send,

§

impl<F> Sync for FnSink<F>
where F: Sync,

§

impl<F> Unpin for FnSink<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for FnSink<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for FnSink<F>
where F: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.