pub trait Blocks:
'static
+ Send
+ Sync
+ Debug {
// Required methods
fn block(&self, target: BlockTarget) -> BoxFut<'static, K2Result<()>>;
fn is_blocked(&self, target: BlockTarget) -> BoxFut<'static, K2Result<bool>>;
fn are_all_blocked(
&self,
targets: Vec<BlockTarget>,
) -> BoxFut<'static, K2Result<bool>>;
}Expand description
Implemented by the Host to signal that a target must be blocked.
Required Methods§
Sourcefn block(&self, target: BlockTarget) -> BoxFut<'static, K2Result<()>>
fn block(&self, target: BlockTarget) -> BoxFut<'static, K2Result<()>>
Used by the Host to block a target.
After blocking a BlockTarget with this method, the Host must also remove the peer
from the crate::PeerStore by calling crate::PeerStore::remove.
Note: This function is not called by Kitsune2 but is used as a suggestion to the host that they should implement functionality to store blocks. It also makes working with blocks simpler once the implementation is a trait-object.
Sourcefn is_blocked(&self, target: BlockTarget) -> BoxFut<'static, K2Result<bool>>
fn is_blocked(&self, target: BlockTarget) -> BoxFut<'static, K2Result<bool>>
Check an individual target to see if they are blocked.
Sourcefn are_all_blocked(
&self,
targets: Vec<BlockTarget>,
) -> BoxFut<'static, K2Result<bool>>
fn are_all_blocked( &self, targets: Vec<BlockTarget>, ) -> BoxFut<'static, K2Result<bool>>
Check a collection of targets and return Ok(true) if all targets are blocked.
Note: If a single target is not blocked then return Ok(false).