pub struct AsyncOnePass<S: AsyncPatchSink> { /* private fields */ }Available on crate feature
async only.Expand description
Writes a file to an async sink as its messages arrive, as OnePass does
to a sink.
use fit_encoder::*;
async fn record(sink: impl AsyncPatchSink, start: Timestamp) -> Result<(), Error> {
let mut file = AsyncOnePass::new(sink, Options::new());
let mut w = file.writer();
w.start(start, &Device::new(Manufacturer::DEVELOPMENT, 1)).await?;
w.session(start, Sport::WALKING, SubSport::GENERIC).await?;
w.record(&Record::new(start).heart_rate(100)).await?;
w.end(start.checked_add(1).unwrap()).await?;
file.finish().await.map_err(|_| Error::Sink)?;
Ok(())
}Implementations§
Source§impl<S: AsyncPatchSink> AsyncOnePass<S>
impl<S: AsyncPatchSink> AsyncOnePass<S>
Sourcepub fn writer(&mut self) -> AsyncWriter<'_, S>
pub fn writer(&mut self) -> AsyncWriter<'_, S>
The writer for the next messages.
Sourcepub async fn finish(self) -> Result<S, FinishError<Self, S::Error>>
pub async fn finish(self) -> Result<S, FinishError<Self, S::Error>>
Writes the file CRC and patches the header’s length in, as
OnePass::finish does.
§Errors
As OnePass::finish’s.
Trait Implementations§
Auto Trait Implementations§
impl<S> Forget for AsyncOnePass<S>
impl<S> Freeze for AsyncOnePass<S>
impl<S> Move for AsyncOnePass<S>
impl<S> RefUnwindSafe for AsyncOnePass<S>
impl<S> Send for AsyncOnePass<S>
impl<S> Sync for AsyncOnePass<S>
impl<S> Unpin for AsyncOnePass<S>
impl<S> UnsafeUnpin for AsyncOnePass<S>
impl<S> UnwindSafe for AsyncOnePass<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more