Skip to main content

MaybeResolvedAddress

Enum MaybeResolvedAddress 

Source
pub enum MaybeResolvedAddress<A, R> {
    Resolved(R),
    Unresolved(A),
}
Expand description

MaybeResolvedAddress is used to represent an address that may or may not be resolved.

Variants§

§

Resolved(R)

The resolved address, which means that can be directly used to communicate with the remote node.

§

Unresolved(A)

The unresolved address, which means that need to be resolved before using it to communicate with the remote node.

Implementations§

Source§

impl<A, R> MaybeResolvedAddress<A, R>

Source

pub fn try_unwrap_resolved( self, ) -> Result<R, TryUnwrapError<MaybeResolvedAddress<A, R>>>

Attempts to unwrap this value to the MaybeResolvedAddress::Resolved variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

Source

pub fn try_unwrap_resolved_ref( &self, ) -> Result<&R, TryUnwrapError<&MaybeResolvedAddress<A, R>>>

Attempts to unwrap this reference to the MaybeResolvedAddress::Resolved variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

Source

pub fn try_unwrap_resolved_mut( &mut self, ) -> Result<&mut R, TryUnwrapError<&mut MaybeResolvedAddress<A, R>>>

Attempts to unwrap this mutable reference to the MaybeResolvedAddress::Resolved variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

Source

pub fn try_unwrap_unresolved( self, ) -> Result<A, TryUnwrapError<MaybeResolvedAddress<A, R>>>

Attempts to unwrap this value to the MaybeResolvedAddress::Unresolved variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

Source

pub fn try_unwrap_unresolved_ref( &self, ) -> Result<&A, TryUnwrapError<&MaybeResolvedAddress<A, R>>>

Attempts to unwrap this reference to the MaybeResolvedAddress::Unresolved variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

Source

pub fn try_unwrap_unresolved_mut( &mut self, ) -> Result<&mut A, TryUnwrapError<&mut MaybeResolvedAddress<A, R>>>

Attempts to unwrap this mutable reference to the MaybeResolvedAddress::Unresolved variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

Source§

impl<A, R> MaybeResolvedAddress<A, R>

Source

pub fn unwrap_resolved(self) -> R

Unwraps this value to the MaybeResolvedAddress::Resolved variant. Panics if this value is of any other type.

Source

pub fn unwrap_resolved_ref(&self) -> &R

Unwraps this reference to the MaybeResolvedAddress::Resolved variant. Panics if this value is of any other type.

Source

pub fn unwrap_resolved_mut(&mut self) -> &mut R

Unwraps this mutable reference to the MaybeResolvedAddress::Resolved variant. Panics if this value is of any other type.

Source

pub fn unwrap_unresolved(self) -> A

Unwraps this value to the MaybeResolvedAddress::Unresolved variant. Panics if this value is of any other type.

Source

pub fn unwrap_unresolved_ref(&self) -> &A

Unwraps this reference to the MaybeResolvedAddress::Unresolved variant. Panics if this value is of any other type.

Source

pub fn unwrap_unresolved_mut(&mut self) -> &mut A

Unwraps this mutable reference to the MaybeResolvedAddress::Unresolved variant. Panics if this value is of any other type.

Source§

impl<A, R> MaybeResolvedAddress<A, R>

Source

pub const fn is_resolved(&self) -> bool

Returns true if this value is of type Resolved. Returns false otherwise

Source

pub const fn is_unresolved(&self) -> bool

Returns true if this value is of type Unresolved. Returns false otherwise

Source§

impl<A, R> MaybeResolvedAddress<A, R>

Source

pub const fn resolved(addr: R) -> MaybeResolvedAddress<A, R>

Creates a resolved address.

Source

pub const fn unresolved(addr: A) -> MaybeResolvedAddress<A, R>

Creates an unresolved address.

Source

pub const fn as_ref(&self) -> MaybeResolvedAddress<&A, &R>

Converts from &MaybeResolvedAddress<A, R> to MaybeResolvedAddress<&A, &R>.

Source

pub const fn as_mut(&mut self) -> MaybeResolvedAddress<&mut A, &mut R>

Converts from &mut MaybeResolvedAddress<A, R> to MaybeResolvedAddress<&mut A, &mut R>.

Trait Implementations§

Source§

impl<A, R> Arbitrary for MaybeResolvedAddress<A, R>
where A: Arbitrary, R: Arbitrary,

Source§

fn arbitrary(g: &mut Gen) -> MaybeResolvedAddress<A, R>

Return an arbitrary value. Read more
Source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
Source§

impl<'arbitrary, A, R> Arbitrary<'arbitrary> for MaybeResolvedAddress<A, R>
where A: Arbitrary<'arbitrary>, R: Arbitrary<'arbitrary>,

Source§

fn arbitrary( u: &mut Unstructured<'arbitrary>, ) -> Result<MaybeResolvedAddress<A, R>, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<MaybeResolvedAddress<A, R>, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<A, R> CheapClone for MaybeResolvedAddress<A, R>
where A: CheapClone, R: CheapClone,

Source§

fn cheap_clone(&self) -> MaybeResolvedAddress<A, R>

Returns a copy of the value.
Source§

impl<A, R> Clone for MaybeResolvedAddress<A, R>
where A: Clone, R: Clone,

Source§

fn clone(&self) -> MaybeResolvedAddress<A, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A, R> Copy for MaybeResolvedAddress<A, R>
where A: Copy, R: Copy,

Source§

impl<A, R> Data for MaybeResolvedAddress<A, R>
where A: Data, R: Data,

Source§

type Ref<'a> = MaybeResolvedAddress<<A as Data>::Ref<'a>, <R as Data>::Ref<'a>>

The reference type of the data.
Source§

fn from_ref( val: <MaybeResolvedAddress<A, R> as Data>::Ref<'_>, ) -> Result<MaybeResolvedAddress<A, R>, DecodeError>

Converts the reference type to the owned type.
Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the data only considering the data itself, (e.g. no length prefix, no wire type).
Source§

fn encode(&self, buf: &mut [u8]) -> Result<usize, EncodeError>

Encodes the message to a buffer. Read more
Source§

const WIRE_TYPE: WireType = WireType::LengthDelimited

The wire type of the data.
Source§

fn encoded_len_with_length_delimited(&self) -> usize

Returns the encoded length of the data including the length delimited.
Source§

fn encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>

Available on crate features alloc or std only.
Encodes the message into a vec.
Source§

fn encode_to_bytes(&self) -> Result<Bytes, EncodeError>

Available on crate features alloc or std only.
Encodes the message into a Bytes.
Source§

fn encode_length_delimited(&self, buf: &mut [u8]) -> Result<usize, EncodeError>

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Result<Vec<u8>, EncodeError>

Available on crate features alloc or std only.
Encodes the message with a length-delimiter into a vec.
Source§

fn encode_length_delimited_to_bytes(&self) -> Result<Bytes, EncodeError>

Available on crate features alloc or std only.
Encodes the message with a length-delimiter into a Bytes.
Source§

fn decode(src: &[u8]) -> Result<(usize, Self), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: &[u8]) -> Result<(usize, Self), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from the buffer.
Source§

impl<'a, A, R> DataRef<'a, MaybeResolvedAddress<A, R>> for MaybeResolvedAddress<<A as Data>::Ref<'a>, <R as Data>::Ref<'a>>
where A: Data, R: Data,

Source§

fn decode( buf: &'a [u8], ) -> Result<(usize, MaybeResolvedAddress<<A as Data>::Ref<'a>, <R as Data>::Ref<'a>>), DecodeError>
where MaybeResolvedAddress<<A as Data>::Ref<'a>, <R as Data>::Ref<'a>>: Sized,

Decodes the reference type from a buffer. Read more
Source§

fn decode_length_delimited(src: &'a [u8]) -> Result<(usize, Self), DecodeError>
where Self: Sized,

Decodes a length-delimited reference instance of the message from the buffer.
Source§

impl<A, R> Debug for MaybeResolvedAddress<A, R>
where A: Debug, R: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de, A, R> Deserialize<'de> for MaybeResolvedAddress<A, R>
where A: Deserialize<'de>, R: Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<MaybeResolvedAddress<A, R>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<A, R> Display for MaybeResolvedAddress<A, R>
where R: Display, A: Display,

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<A, R> Eq for MaybeResolvedAddress<A, R>
where A: Eq, R: Eq,

Source§

impl<A, R> Hash for MaybeResolvedAddress<A, R>
where A: Hash, R: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<A, R> PartialEq for MaybeResolvedAddress<A, R>
where A: PartialEq, R: PartialEq,

Source§

fn eq(&self, other: &MaybeResolvedAddress<A, R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A, R> Serialize for MaybeResolvedAddress<A, R>
where A: Serialize, R: Serialize,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<A, R> StructuralPartialEq for MaybeResolvedAddress<A, R>
where A: PartialEq, R: PartialEq,

Auto Trait Implementations§

§

impl<A, R> Freeze for MaybeResolvedAddress<A, R>
where R: Freeze, A: Freeze,

§

impl<A, R> RefUnwindSafe for MaybeResolvedAddress<A, R>

§

impl<A, R> Send for MaybeResolvedAddress<A, R>
where R: Send, A: Send,

§

impl<A, R> Sync for MaybeResolvedAddress<A, R>
where R: Sync, A: Sync,

§

impl<A, R> Unpin for MaybeResolvedAddress<A, R>
where R: Unpin, A: Unpin,

§

impl<A, R> UnsafeUnpin for MaybeResolvedAddress<A, R>
where R: UnsafeUnpin, A: UnsafeUnpin,

§

impl<A, R> UnwindSafe for MaybeResolvedAddress<A, R>
where R: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more