Skip to content

Commit

Permalink
some api adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuwu committed Dec 18, 2023
1 parent b48d98f commit d8adaa2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/address.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::net::SocketAddr;

/// An address type, for use with the [`Socket`](`crate::Socket`) trait.
pub trait Address: Clone {
pub trait Address: Sized + Clone {
/// Are the two addresses the same host?
///
/// For IP based addresses, this checks if the IP of two addresses are the same.
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub enum Error {
/// Failed to send.
#[error("Failed to send.")]
FailedToSend,
/// Failed to receive.
#[error("Failed to receive.")]
FailedToReceive,
/// A bad parameter was passed to the function.
#[error("A bad parameter was passed to the function.")]
BadParameter,
Expand Down
5 changes: 5 additions & 0 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ impl<S: Socket> Host<S> {
}
}

/// Get the maximum number of peers that can connect to this host.
pub fn peer_limit(&self) -> usize {
self.peers.len()
}

/// Get a reference to a single peer.
///
/// # Note
Expand Down
2 changes: 1 addition & 1 deletion src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub trait Socket: Sized {
///
/// An example is the standard library's [`std::net::SocketAddr`], used with
/// [`std::net::UdpSocket`].
type PeerAddress: Address;
type PeerAddress: Address + 'static;
/// Errors returned by this socket.
type Error: std::error::Error + Send + Sync + 'static;

Expand Down

0 comments on commit d8adaa2

Please sign in to comment.