Skip to main content

CaptureFile

Struct CaptureFile 

Source
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

Source

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.

Source

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”.

Source

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.

Source

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.

Source

pub fn path(&self) -> Option<&Path>

The path of the file this was opened from; None for CaptureFile::from_reader.

Source

pub fn params(&self) -> &WorldParams

The world params.

Source

pub fn len(&self) -> usize

The number of tiles indexed.

Source

pub fn is_empty(&self) -> bool

Whether no tile is indexed.

Source

pub fn bounds(&self) -> Option<[i32; 4]>

The bounding range [x0, z0, x1, z1] of the indexed tiles, None when there is none.

Source

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§

Source§

impl Debug for CaptureFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.