pub struct Peer {
pub id: Option<[u8; 32]>,
pub addr: SocketAddr,
pub referrer: Option<SocketAddr>,
}Fields§
§id: Option<[u8; 32]>§addr: SocketAddr§referrer: Option<SocketAddr>Referrer that told us about this node.
Implementations§
Source§impl Peer
impl Peer
pub fn socketv4(&self) -> Result<&SocketAddrV4>
pub fn new(addr: SocketAddr) -> Self
pub fn with_id(self, id: Option<[u8; 32]>) -> Self
pub fn with_referrer(self, referrer: Option<SocketAddr>) -> Self
Trait Implementations§
Source§impl CompactEncoding for Peer
impl CompactEncoding for Peer
Source§fn encoded_size(&self) -> Result<usize, EncodingError>
fn encoded_size(&self) -> Result<usize, EncodingError>
The size in bytes required to encode
self.Source§fn encode<'a>(
&self,
buffer: &'a mut [u8],
) -> Result<&'a mut [u8], EncodingError>
fn encode<'a>( &self, buffer: &'a mut [u8], ) -> Result<&'a mut [u8], EncodingError>
Encode
self into buffer returning the remainder of buffer.Source§fn decode(buffer: &[u8]) -> Result<(Self, &[u8]), EncodingError>where
Self: Sized,
fn decode(buffer: &[u8]) -> Result<(Self, &[u8]), EncodingError>where
Self: Sized,
Decode a value from the given
buffer of the type specified by the Decode type parameter
(which defaults to Self). Returns the decoded value and remaining undecoded bytes.Source§fn to_encoded_bytes(&self) -> Result<Box<[u8]>, EncodingError>
fn to_encoded_bytes(&self) -> Result<Box<[u8]>, EncodingError>
Encode
self into a Vec<u8>. This is just a helper method for creating a buffer and
encoding to it in one step. Read moreSource§fn create_buffer(&self) -> Result<Box<[u8]>, EncodingError>
fn create_buffer(&self) -> Result<Box<[u8]>, EncodingError>
Create an empty buffer of the correct size for encoding
self to. This is just a helper
method for: encoding to it in one step. Read moreSource§fn encode_with_len<'a>(
&self,
buffer: &'a mut [u8],
) -> Result<(&'a mut [u8], usize), EncodingError>
fn encode_with_len<'a>( &self, buffer: &'a mut [u8], ) -> Result<(&'a mut [u8], usize), EncodingError>
Like
CompactEncoding::encode but also return the number of bytes encoded.Source§fn decode_with_len(
buffer: &[u8],
) -> Result<(Decode, &[u8], usize), EncodingError>where
Decode: Sized,
fn decode_with_len(
buffer: &[u8],
) -> Result<(Decode, &[u8], usize), EncodingError>where
Decode: Sized,
Like
CompactEncoding::decode but also return the number of bytes decoded.impl Eq for Peer
Source§impl From<&Peer> for SocketAddr
impl From<&Peer> for SocketAddr
Source§impl From<&SocketAddr> for Peer
impl From<&SocketAddr> for Peer
Source§fn from(value: &SocketAddr) -> Self
fn from(value: &SocketAddr) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddr> for Peer
impl From<SocketAddr> for Peer
Source§fn from(value: SocketAddr) -> Self
fn from(value: SocketAddr) -> Self
Converts to this type from the input type.
Source§impl Ord for Peer
impl Ord for Peer
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Peer
impl PartialOrd for Peer
impl StructuralPartialEq for Peer
Source§impl VecEncodable for Peer
impl VecEncodable for Peer
Source§fn vec_encoded_size(vec: &[Self]) -> Result<usize, EncodingError>where
Self: Sized,
fn vec_encoded_size(vec: &[Self]) -> Result<usize, EncodingError>where
Self: Sized,
Calculate the resulting size in bytes of
vecSource§fn vec_encode<'a>(
vec: &[Self],
buffer: &'a mut [u8],
) -> Result<&'a mut [u8], EncodingError>where
Self: Sized + CompactEncoding,
fn vec_encode<'a>(
vec: &[Self],
buffer: &'a mut [u8],
) -> Result<&'a mut [u8], EncodingError>where
Self: Sized + CompactEncoding,
Encode
vec to bufferSource§fn vec_decode(buffer: &[u8]) -> Result<(Vec<Decode>, &[u8]), EncodingError>where
Decode: Sized + CompactEncoding,
fn vec_decode(buffer: &[u8]) -> Result<(Vec<Decode>, &[u8]), EncodingError>where
Decode: Sized + CompactEncoding,
Decode
Vec<Decode> from bufferAuto Trait Implementations§
impl Freeze for Peer
impl RefUnwindSafe for Peer
impl Send for Peer
impl Sync for Peer
impl Unpin for Peer
impl UnsafeUnpin for Peer
impl UnwindSafe for Peer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more