pub struct Section { /* private fields */ }
Implementations§
source§impl Section
impl Section
A section is used to store items on disk and retrieve them.
Since a section can be become full, it is recommended to use the higher level interfaces that manage the creation of new sections for you, notably a Queue.
sourcepub fn is_eof(offset: u32) -> bool
pub fn is_eof(offset: u32) -> bool
Determines if a theoretical offset is past the end of this section.
sourcepub fn new(path: &PathBuf) -> Result<Section>
pub fn new(path: &PathBuf) -> Result<Section>
Opens the section, creating it if it doesn’t exist.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Determines if the section is empty, i.e. no items have been written to it.
sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Determines if the section is full, i.e. it will not accept any more items.
sourcepub fn last_id(&mut self) -> Option<u32>
pub fn last_id(&mut self) -> Option<u32>
Determines the last id that was written, or None
if
empty.
sourcepub fn sync(&mut self) -> Result<()>
pub fn sync(&mut self) -> Result<()>
Forces all items that have been appended to be written out to disk.
sourcepub fn stream(
&self,
id: Option<u32>
) -> Result<impl Iterator<Item = Result<Item>>>
pub fn stream(
&self,
id: Option<u32>
) -> Result<impl Iterator<Item = Result<Item>>>
Iterate over items stored in this section, starting at the specified id (inclusive, if provided).
Note that this skips over items that were only partially written due to crash or power loss, which is typically the preferred behavior.
sourcepub fn stream_with_truncated(
&self,
id: Option<u32>
) -> Result<impl Iterator<Item = Result<Decoded>>>
pub fn stream_with_truncated(
&self,
id: Option<u32>
) -> Result<impl Iterator<Item = Result<Decoded>>>
Iterate over items stored in this section, starting at the specified id (inclusive, if provided).
Note that this DOES NOT skip over items that may have been partially written. This is not a usual mode of operation, but may be useful for some systems.