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
impl MessageSource
sourcepub async fn new(file_id: FileId, mode: StreamMode) -> Result<Self, FileErr>
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.
pub fn file_header(&self) -> &Header
sourcepub async fn rewind(&mut self, target: SeqPos) -> Result<u32, FileErr>
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.
sourcepub async fn seek(
&mut self,
stream_key: &StreamKey,
shard_id: &ShardId,
to: SeekTarget,
) -> Result<(), FileErr>
pub async fn seek( &mut self, stream_key: &StreamKey, shard_id: &ShardId, to: SeekTarget, ) -> Result<(), FileErr>
Warning: This future must not be canceled.
sourcepub async fn switch_to(&mut self, stype: FileSourceType) -> Result<(), FileErr>
pub async fn switch_to(&mut self, stype: FileSourceType) -> Result<(), FileErr>
Switch the file source type.
Warning: This future must not be canceled.
sourcepub fn beacon(&self) -> (u32, &[Marker])
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
pub fn offset(&self) -> u64
Trait Implementations§
source§impl BeaconReader for MessageSource
impl BeaconReader for MessageSource
source§impl ByteSource for MessageSource
impl ByteSource for MessageSource
§type Future<'a> = Pin<Box<dyn Future<Output = Result<Bytes, FileErr>> + Send + 'a>>
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<'_>
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.