net-pool 0.5.1

A set of types for network connection pool.
Documentation
use std::hash::Hasher;

#[inline]
pub fn bytes_to_hash_code(msg: &[u8]) -> u64 {
    let mut h = std::hash::DefaultHasher::new();
    h.write(msg);
    h.finish()
}

#[inline]
pub fn socketaddr_to_hash_code(addr: &std::net::SocketAddr) -> u64 {
    let ip = socketaddr_to_ip_string(addr);
    bytes_to_hash_code(ip.as_bytes())
}

#[inline]
pub(crate) fn socketaddr_to_ip_string(addr: &std::net::SocketAddr) -> String {
    format!("{}:{}", addr.ip().to_string(), addr.port())
}