Trait subspace_farmer::farm::Farm

source ·
pub trait Farm {
    // Required methods
    fn id(&self) -> &FarmId;
    fn total_sectors_count(&self) -> SectorIndex;
    fn plotted_sectors(&self) -> Arc<dyn PlottedSectors + 'static>;
    fn piece_reader(&self) -> Arc<dyn PieceReader + 'static>;
    fn on_sector_update(
        &self,
        callback: HandlerFn<(SectorIndex, SectorUpdate)>,
    ) -> Box<dyn HandlerId>;
    fn on_farming_notification(
        &self,
        callback: HandlerFn<FarmingNotification>,
    ) -> Box<dyn HandlerId>;
    fn on_solution(
        &self,
        callback: HandlerFn<SolutionResponse>,
    ) -> Box<dyn HandlerId>;
    fn run(self: Box<Self>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>;
}
Expand description

Abstract farm implementation

Required Methods§

source

fn id(&self) -> &FarmId

ID of this farm

source

fn total_sectors_count(&self) -> SectorIndex

Number of sectors in this farm

source

fn plotted_sectors(&self) -> Arc<dyn PlottedSectors + 'static>

Get plotted sectors instance

source

fn piece_reader(&self) -> Arc<dyn PieceReader + 'static>

Get piece reader to read plotted pieces later

source

fn on_sector_update( &self, callback: HandlerFn<(SectorIndex, SectorUpdate)>, ) -> Box<dyn HandlerId>

Subscribe to sector updates

source

fn on_farming_notification( &self, callback: HandlerFn<FarmingNotification>, ) -> Box<dyn HandlerId>

Subscribe to farming notifications

source

fn on_solution( &self, callback: HandlerFn<SolutionResponse>, ) -> Box<dyn HandlerId>

Subscribe to new solution notification

source

fn run(self: Box<Self>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>

Run and wait for background threads to exit or return an error

Implementations on Foreign Types§

source§

impl<T> Farm for Box<T>
where T: Farm + ?Sized,

source§

fn id(&self) -> &FarmId

source§

fn total_sectors_count(&self) -> SectorIndex

source§

fn plotted_sectors(&self) -> Arc<dyn PlottedSectors + 'static>

source§

fn piece_reader(&self) -> Arc<dyn PieceReader + 'static>

source§

fn on_sector_update( &self, callback: HandlerFn<(SectorIndex, SectorUpdate)>, ) -> Box<dyn HandlerId>

source§

fn on_farming_notification( &self, callback: HandlerFn<FarmingNotification>, ) -> Box<dyn HandlerId>

source§

fn on_solution( &self, callback: HandlerFn<SolutionResponse>, ) -> Box<dyn HandlerId>

source§

fn run(self: Box<Self>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>

Implementors§