Skip to main content

Farm

Trait Farm 

Source
pub trait Farm {
    // Required methods
    fn id(&self) -> &FarmId;
    fn total_sectors_count(&self) -> u16;
    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) -> u16

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

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) -> u16

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§