pub trait NodeRestriction: Send + Sync {
// Required method
fn r_is_ok(&self, router: &RouterStatusEntry) -> bool;
}Expand description
Interface for node restriction policies.
Implementations of this trait define criteria for filtering relay nodes.
Multiple restrictions can be combined using NodeRestrictionList.
§Implementing Custom Restrictions
Create custom restrictions by implementing this trait:
use vanguards_rs::node_selection::NodeRestriction;
use stem_rs::descriptor::router_status::RouterStatusEntry;
struct BandwidthRestriction {
min_bandwidth: u64,
}
impl NodeRestriction for BandwidthRestriction {
fn r_is_ok(&self, router: &RouterStatusEntry) -> bool {
router.bandwidth.unwrap_or(0) >= self.min_bandwidth
}
}§Thread Safety
Implementations must be Send + Sync to allow use across threads.
§See Also
FlagsRestriction- Built-in restriction for router flagsNodeRestrictionList- Combine multiple restrictions