pub struct SingleDiskFarm { /* private fields */ }Expand description
Single disk farm abstraction is a container for everything necessary to plot/farm with a single disk.
Farm starts operating during creation and doesn’t stop until dropped (or error happens).
Implementations§
Source§impl SingleDiskFarm
impl SingleDiskFarm
Sourcepub const METADATA_FILE: &'static str = "metadata.bin"
pub const METADATA_FILE: &'static str = "metadata.bin"
Name of the metadata file
Sourcepub async fn new<NC, PosTable>(
options: SingleDiskFarmOptions<'_, NC>,
farm_index: usize,
) -> Result<Self, SingleDiskFarmError>
pub async fn new<NC, PosTable>( options: SingleDiskFarmOptions<'_, NC>, farm_index: usize, ) -> Result<Self, SingleDiskFarmError>
Create new single disk farm instance
Sourcepub fn collect_summary(directory: PathBuf) -> SingleDiskFarmSummary
pub fn collect_summary(directory: PathBuf) -> SingleDiskFarmSummary
Collect summary of single disk farm for presentational purposes
Sourcepub fn effective_disk_usage(
directory: &Path,
cache_percentage: u8,
) -> Result<u64, SingleDiskFarmError>
pub fn effective_disk_usage( directory: &Path, cache_percentage: u8, ) -> Result<u64, SingleDiskFarmError>
Effective on-disk allocation of the files related to the farm (takes some buffer space into consideration).
This is a helpful number in case some files were not allocated properly or were removed and do not correspond to allocated space in the farm info accurately.
Sourcepub fn read_all_sectors_metadata(
directory: &Path,
) -> Result<Vec<SectorMetadataChecksummed>>
pub fn read_all_sectors_metadata( directory: &Path, ) -> Result<Vec<SectorMetadataChecksummed>>
Read all sectors metadata
Sourcepub fn info(&self) -> &SingleDiskFarmInfo
pub fn info(&self) -> &SingleDiskFarmInfo
Info of this farm
Sourcepub fn total_sectors_count(&self) -> u16
pub fn total_sectors_count(&self) -> u16
Number of sectors in this farm
Sourcepub fn plotted_sectors(&self) -> SingleDiskPlottedSectors
pub fn plotted_sectors(&self) -> SingleDiskPlottedSectors
Read information about sectors plotted so far
Sourcepub fn piece_cache(&self) -> SingleDiskPieceCache
pub fn piece_cache(&self) -> SingleDiskPieceCache
Get piece cache instance
Sourcepub fn plot_cache(&self) -> DiskPlotCache
pub fn plot_cache(&self) -> DiskPlotCache
Get plot cache instance
Sourcepub fn piece_reader(&self) -> DiskPieceReader
pub fn piece_reader(&self) -> DiskPieceReader
Get piece reader to read plotted pieces later
Sourcepub fn on_sector_update(
&self,
callback: HandlerFn<(SectorIndex, SectorUpdate)>,
) -> HandlerId
pub fn on_sector_update( &self, callback: HandlerFn<(SectorIndex, SectorUpdate)>, ) -> HandlerId
Subscribe to sector updates
Sourcepub fn on_farming_notification(
&self,
callback: HandlerFn<FarmingNotification>,
) -> HandlerId
pub fn on_farming_notification( &self, callback: HandlerFn<FarmingNotification>, ) -> HandlerId
Subscribe to farming notifications
Sourcepub fn on_solution(&self, callback: HandlerFn<SolutionResponse>) -> HandlerId
pub fn on_solution(&self, callback: HandlerFn<SolutionResponse>) -> HandlerId
Subscribe to new solution notification
Sourcepub async fn run(self) -> Result<()>
pub async fn run(self) -> Result<()>
Run and wait for background threads to exit or return an error
Sourcepub fn wipe(directory: &Path) -> Result<()>
pub fn wipe(directory: &Path) -> Result<()>
Wipe everything that belongs to this single disk farm
Sourcepub fn scrub(
directory: &Path,
disable_farm_locking: bool,
target: ScrubTarget,
dry_run: bool,
) -> Result<(), SingleDiskFarmScrubError>
pub fn scrub( directory: &Path, disable_farm_locking: bool, target: ScrubTarget, dry_run: bool, ) -> Result<(), SingleDiskFarmScrubError>
Check the farm for corruption and repair errors (caused by disk errors or something else), returns an error when irrecoverable errors occur.
Trait Implementations§
Source§impl Debug for SingleDiskFarm
impl Debug for SingleDiskFarm
Source§impl Drop for SingleDiskFarm
impl Drop for SingleDiskFarm
Source§impl Farm for SingleDiskFarm
impl Farm for SingleDiskFarm
Source§fn total_sectors_count(&self) -> u16
fn total_sectors_count(&self) -> u16
Source§fn plotted_sectors(&self) -> Arc<dyn PlottedSectors + 'static>
fn plotted_sectors(&self) -> Arc<dyn PlottedSectors + 'static>
Source§fn piece_reader(&self) -> Arc<dyn PieceReader + 'static>
fn piece_reader(&self) -> Arc<dyn PieceReader + 'static>
Source§fn on_sector_update(
&self,
callback: HandlerFn<(SectorIndex, SectorUpdate)>,
) -> Box<dyn HandlerId>
fn on_sector_update( &self, callback: HandlerFn<(SectorIndex, SectorUpdate)>, ) -> Box<dyn HandlerId>
Source§fn on_farming_notification(
&self,
callback: HandlerFn<FarmingNotification>,
) -> Box<dyn HandlerId>
fn on_farming_notification( &self, callback: HandlerFn<FarmingNotification>, ) -> Box<dyn HandlerId>
Source§fn on_solution(
&self,
callback: HandlerFn<SolutionResponse>,
) -> Box<dyn HandlerId>
fn on_solution( &self, callback: HandlerFn<SolutionResponse>, ) -> Box<dyn HandlerId>
Auto Trait Implementations§
impl !Freeze for SingleDiskFarm
impl !RefUnwindSafe for SingleDiskFarm
impl Send for SingleDiskFarm
impl !Sync for SingleDiskFarm
impl Unpin for SingleDiskFarm
impl !UnwindSafe for SingleDiskFarm
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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