pub struct PeerBandwidth(/* private fields */);
Expand description
The message to tell the client-side bandwidth. This has 2 ways of comparision by which field you specifies.
§Examples
use sheave_core::messages::{
LimitType,
PeerBandwidth,
};
let peer_bandwidth = PeerBandwidth::default();
// When you compare this message with a bandwidth number.
assert!(2500000u32 == peer_bandwidth);
assert!(0 <= peer_bandwidth);
// When you compare this message with a limit type.
assert!(LimitType::default() == peer_bandwidth)
Implementations§
Source§impl PeerBandwidth
impl PeerBandwidth
Sourcepub fn new(peer_bandwidth: u32, limit_type: LimitType) -> Self
pub fn new(peer_bandwidth: u32, limit_type: LimitType) -> Self
Constructs a PeerBandwidth message.
pub fn get_inner_bandwidth(&self) -> u32
pub fn get_inner_limit_type(&self) -> LimitType
Trait Implementations§
Source§impl ChunkData for PeerBandwidth
impl ChunkData for PeerBandwidth
const CHANNEL: Channel = Channel::Network
const MESSAGE_TYPE: MessageType = MessageType::PeerBandwidth
Source§impl Clone for PeerBandwidth
impl Clone for PeerBandwidth
Source§fn clone(&self) -> PeerBandwidth
fn clone(&self) -> PeerBandwidth
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PeerBandwidth
impl Debug for PeerBandwidth
Source§impl Decoder<PeerBandwidth> for ByteBuffer
impl Decoder<PeerBandwidth> for ByteBuffer
Source§fn decode(&mut self) -> IOResult<PeerBandwidth>
fn decode(&mut self) -> IOResult<PeerBandwidth>
Decodes bytes into a PeerBandwidth message.
§Errors
When this buffer didn’t remain at least 5 bytes.
§Examples
use sheave_core::{
ByteBuffer,
Decoder,
messages::PeerBandwidth
};
let mut buffer = ByteBuffer::default();
buffer.put_u32_be(u32::default());
buffer.put_u8(u8::default());
assert!(Decoder::<PeerBandwidth>::decode(&mut buffer).is_ok())
Source§impl Default for PeerBandwidth
impl Default for PeerBandwidth
Source§fn default() -> Self
fn default() -> Self
Constructs a PeerBandwidth message with the default bandwidth and the default limit type (2500000 in bits, 2 (Dynamic)).
§Examples
use sheave_core::messages::{
LimitType,
PeerBandwidth
};
let peer_bandwidth = PeerBandwidth::default();
assert_eq!(2500000u32, peer_bandwidth);
assert_eq!(LimitType::default(), peer_bandwidth)
Source§impl Div<u32> for PeerBandwidth
impl Div<u32> for PeerBandwidth
Source§impl Encoder<PeerBandwidth> for ByteBuffer
impl Encoder<PeerBandwidth> for ByteBuffer
Source§fn encode(&mut self, peer_bandwidth: &PeerBandwidth)
fn encode(&mut self, peer_bandwidth: &PeerBandwidth)
Encodes a PeerBandwidth message into bytes.
Source§impl Ord for PeerBandwidth
impl Ord for PeerBandwidth
Source§fn cmp(&self, other: &PeerBandwidth) -> Ordering
fn cmp(&self, other: &PeerBandwidth) -> Ordering
1.21.0 · 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 PartialEq<Acknowledgement> for PeerBandwidth
impl PartialEq<Acknowledgement> for PeerBandwidth
Source§impl PartialEq<LimitType> for PeerBandwidth
impl PartialEq<LimitType> for PeerBandwidth
Source§impl PartialEq<PeerBandwidth> for Acknowledgement
impl PartialEq<PeerBandwidth> for Acknowledgement
Source§impl PartialEq<PeerBandwidth> for LimitType
impl PartialEq<PeerBandwidth> for LimitType
Source§impl PartialEq<PeerBandwidth> for u32
impl PartialEq<PeerBandwidth> for u32
Source§impl PartialEq<u32> for PeerBandwidth
impl PartialEq<u32> for PeerBandwidth
Source§impl PartialEq for PeerBandwidth
impl PartialEq for PeerBandwidth
Source§impl PartialOrd<Acknowledgement> for PeerBandwidth
impl PartialOrd<Acknowledgement> for PeerBandwidth
Source§impl PartialOrd<PeerBandwidth> for Acknowledgement
impl PartialOrd<PeerBandwidth> for Acknowledgement
Source§impl PartialOrd<PeerBandwidth> for u32
impl PartialOrd<PeerBandwidth> for u32
Source§impl PartialOrd<u32> for PeerBandwidth
impl PartialOrd<u32> for PeerBandwidth
Source§impl PartialOrd for PeerBandwidth
impl PartialOrd for PeerBandwidth
impl Copy for PeerBandwidth
impl Eq for PeerBandwidth
impl StructuralPartialEq for PeerBandwidth
Auto Trait Implementations§
impl Freeze for PeerBandwidth
impl RefUnwindSafe for PeerBandwidth
impl Send for PeerBandwidth
impl Sync for PeerBandwidth
impl Unpin for PeerBandwidth
impl UnwindSafe for PeerBandwidth
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