pub trait ScopeableAddress {
    type Scope: Scope;

    // Required method
    fn scope(&self) -> Self::Scope;
Expand description

An address that can be tied to some scope identifier.

ScopeableAddress is implemented by address types for which some values can have extra scoping information attached. Notably, some IPv6 addresses belonging to a particular scope class require extra metadata to identify the scope identifier or “zone”. The zone is typically the networking interface identifier.

Address types which are never in any identified scope may still implement ScopeableAddress by setting the associated Scope type to (), which has the effect of ensuring that a zone can never be associated with an address (since the implementation of Scope::can_have_zone for () always returns false).

Required Associated Types§


type Scope: Scope

The type of all non-global scopes.

Required Methods§


fn scope(&self) -> Self::Scope

The scope of this address.

scope must maintain the invariant that, if it is called twice on the same object, and in between those two calls, no code has operated on a mutable reference to that object, both calls will return the same value. This property is required in order to implement AddrAndZone. Note that, since this is not an unsafe trait, unsafe code may NOT rely on this property for its soundness. However, code MAY rely on this property for its correctness.

If this type also implements SpecifiedAddress then a.scope().can_have_zone() implies a.is_specified(), since unspecified addresses are always global, and the global scope cannot have a zone.