Struct sea_streamer_file::MessageSource

source ·
pub struct MessageSource { /* private fields */ }
Expand description

A high level file reader that demux messages and beacon

Implementations§

source§

impl MessageSource

source

pub async fn new(file_id: FileId, mode: StreamMode) -> Result<Self, FileErr>

Creates a new message source. First, the stream Header is read from the file’s beginning.

If StreamMode is Live, it will fast forward to the file’s end.

source

pub fn file_header(&self) -> &Header

source

pub async fn rewind(&mut self, target: SeqPos) -> Result<u32, FileErr>

Rewind the message stream to a coarse position. SeqNo is regarded as the N-th beacon. Returns the current location in terms of N-th beacon.

Warning: This future must not be canceled.

source

pub async fn seek( &mut self, stream_key: &StreamKey, shard_id: &ShardId, to: SeekTarget ) -> Result<(), FileErr>

Warning: This future must not be canceled.

source

pub async fn switch_to(&mut self, stype: FileSourceType) -> Result<(), FileErr>

Switch the file source type.

Warning: This future must not be canceled.

source

pub async fn next(&mut self) -> Result<Message, FileErr>

Read the next message.

source

pub fn beacon(&self) -> (u32, &[Marker])

Get the most recent Beacon and it’s index. Note that it is cleared (rather than carry-over) on each Beacon point.

Beacon index starts from 1 (don’t wary, because 0 is the header), and we have the following equation:

ⓘ
file offset = beacon index * beacon interval
source

pub fn offset(&self) -> u64

Trait Implementations§

source§

impl BeaconReader for MessageSource

§

type Future<'a> = Pin<Box<dyn Future<Output = Result<Beacon, FileErr>> + Send + 'a>>

source§

fn survey(&mut self, at: NonZeroU32) -> Self::Future<'_>

source§

fn max_beacons(&self) -> u32

Returns the max N-th Beacon
source§

impl ByteSource for MessageSource

§

type Future<'a> = Pin<Box<dyn Future<Output = Result<Bytes, FileErr>> + Send + 'a>>

Too complex to unroll by hand. Let’s just box it.

source§

fn request_bytes(&mut self, size: usize) -> Self::Future<'_>

Although this is exposed as public. Do not call this directly, this will interfere the Message Stream.

Auto Trait Implementations§

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>,

§

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>,

§

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.