pub struct AddrPolicy { /* private fields */ }
Expand description

A sequence of rules that are applied to an address:port until one matches.

Each rule is of the form “accept PATTERN” or “reject PATTERN”, where every pattern describes a set of addresses and ports. Address sets are given as a prefix of 0-128 bits that the address must have; port sets are given as a low-bound and high-bound that the target port might lie between.

Relays use this type for defining their own policies, and for publishing their IPv4 policies. Clients instead use super::portpolicy::PortPolicy objects to view a summary of the relays’ declared policies.

An example IPv4 policy might be:

 reject *:25
 reject 127.0.0.0/8:*
 reject 192.168.0.0/16:*
 accept *:80
 accept *:443
 accept *:9000-65535
 reject *:*

Implementations

Apply this policy to an address:port combination

We do this by applying each rule in sequence, until one matches.

Returns None if no rule matches.

As allows, but accept a SocketAddr.

Create a new AddrPolicy that matches nothing.

Add a new rule to this policy.

The newly added rule is applied after all previous rules. It matches all addresses and ports covered by AddrPortPattern.

If accept is true, the rule is to accept addresses that match; if accept is false, the rule rejects such addresses.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.