quickner/
entity.rs

1use std::hash::Hash;
2
3use serde::{Deserialize, Serialize};
4
5/// An entity is a text with a label
6///
7/// This object is used to hold the label used to
8/// annotate the text.
9#[derive(Eq, Serialize, Deserialize, Clone, Debug)]
10pub struct Entity {
11    pub name: String,
12    pub label: String,
13}
14
15impl PartialEq for Entity {
16    fn eq(&self, other: &Self) -> bool {
17        self.name == other.name && self.label == other.label
18    }
19}
20
21impl Hash for Entity {
22    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
23        self.name.hash(state);
24        self.label.hash(state);
25    }
26}