pub struct CaptureFile { /* private fields */ }Expand description
A capture that is indexed, not loaded: opening reads the world params and the (x, z) of every
record (8 bytes each, skipping the rest by seeking), and CaptureFile::tile reads one record on
demand. Memory is proportional to the number of indexed tiles (at most the range) plus the tiles in
flight, so a range of a multi-gigabyte capture needs only the tiles of that range. The format is the
one of Capture; use Capture::read only for small captures that you want in memory.
Implementations§
Source§impl CaptureFile
impl CaptureFile
Sourcepub fn open(
path: &Path,
options: &CaptureFileOptions,
warnings: &mut dyn WarningSink,
) -> Result<Self>
pub fn open( path: &Path, options: &CaptureFileOptions, warnings: &mut dyn WarningSink, ) -> Result<Self>
Opens and indexes the capture file at path; see CaptureFile::from_reader.
§Errors
The file cannot be opened, and the errors of CaptureFile::from_reader.
Sourcepub fn from_reader<R: Read + Seek + Send + 'static>(
reader: R,
options: &CaptureFileOptions,
warnings: &mut dyn WarningSink,
) -> Result<Self>
pub fn from_reader<R: Read + Seek + Send + 'static>( reader: R, options: &CaptureFileOptions, warnings: &mut dyn WarningSink, ) -> Result<Self>
Indexes a capture read from reader. A capture cut short keeps every complete record; a partial
trailing block is ignored. A tile captured twice keeps the later copy. Records outside the world
grid are ignored (one note says how many); records outside options.range are skipped. The
records are not parsed here: a malformed record is reported by CaptureFile::tile, and fails
that tile only (not the whole capture, as Capture::read does). The records are counted, not
the tiles: a capture with more records than the world has tiles is refused even if some of them
repeat a tile (a recording never writes a tile twice).
§Errors
The errors of Capture::read for the header and the world block, “invalid capture block size
N”, “message truncated” for a record too short to hold its coordinates, “capture has more
records than the world has tiles” and “too many tiles to index”.
Sourcepub fn indexed_range(&self) -> Option<[i32; 4]>
pub fn indexed_range(&self) -> Option<[i32; 4]>
The part of the world grid that was indexed, [x0, z0, x1, z1] inclusive: the range the file was
opened with, clipped to the grid. None when that range was empty.
Sourcepub fn covers(&self, range: Option<[i32; 4]>) -> bool
pub fn covers(&self, range: Option<[i32; 4]>) -> bool
Whether every tile of range (clipped to the grid like the range of a run; None is the whole
grid) was indexed, so that a tile this capture does not return is really missing from the file.
Sourcepub fn path(&self) -> Option<&Path>
pub fn path(&self) -> Option<&Path>
The path of the file this was opened from; None for CaptureFile::from_reader.
Sourcepub fn params(&self) -> &WorldParams
pub fn params(&self) -> &WorldParams
The world params.
Sourcepub fn bounds(&self) -> Option<[i32; 4]>
pub fn bounds(&self) -> Option<[i32; 4]>
The bounding range [x0, z0, x1, z1] of the indexed tiles, None when there is none.
Sourcepub fn tile(&self, x: i32, z: i32) -> Result<Option<TileInput>>
pub fn tile(&self, x: i32, z: i32) -> Result<Option<TileInput>>
Reads and parses tile (x, z); None when the capture (or the indexed range) lacks it.
§Errors
A read error keeps its kind (the file may be unreadable at the moment); a malformed record is
io::ErrorKind::InvalidData with the errors of TileInput::parse.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CaptureFile
impl RefUnwindSafe for CaptureFile
impl Send for CaptureFile
impl Sync for CaptureFile
impl Unpin for CaptureFile
impl UnsafeUnpin for CaptureFile
impl UnwindSafe for CaptureFile
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more