pub trait Node {
// Required method
fn get_key(&self) -> &str;
}Expand description
Trait representing a node in a consistent hash ring
Any type that implements this trait can be used as a node in consistent hashing.
The key returned by get_key() will be used for hash mapping on the ring.
§Example
use rocketmq_common::common::consistenthash::Node;
struct ServerNode {
address: String,
}
impl Node for ServerNode {
fn get_key(&self) -> &str {
&self.address
}
}
let node = ServerNode {
address: "192.168.1.1:8080".to_string(),
};
assert_eq!(node.get_key(), "192.168.1.1:8080");Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".