pub struct LabelMap {
pub map: BiHashMap<Hash40, String>,
pub strict: bool,
}
Fields§
§map: BiHashMap<Hash40, String>
A bidirectional map to associate hashes and their labels
strict: bool
Controls whether the default hash40 method is used instead of returning None when you try to find the hash of a label which is not present in the map.
By default, set to false
Implementations§
source§impl LabelMap
impl LabelMap
sourcepub fn add_labels<I: IntoIterator<Item = String>>(&mut self, labels: I)
pub fn add_labels<I: IntoIterator<Item = String>>(&mut self, labels: I)
Inserts labels into the map, using the default hash40 method for the hash
sourcepub fn add_custom_labels<I: Iterator<Item = (Hash40, String)>>(
&mut self,
labels: I
)
pub fn add_custom_labels<I: Iterator<Item = (Hash40, String)>>( &mut self, labels: I )
Inserts labels into the map, providing both the hash and the associated label.
Users can insert a label for a hash, even if the hash of the label inserted doesn’t match the paired hash. This allows custom descriptive labels when the true label is not known for the hash.
sourcepub fn read_labels<P: AsRef<Path>>(path: P) -> Result<Vec<String>, Error>
pub fn read_labels<P: AsRef<Path>>(path: P) -> Result<Vec<String>, Error>
Opens a file and returns a list of newline-separated labels
sourcepub fn read_custom_labels<P: AsRef<Path>>(
path: P
) -> Result<Vec<(Hash40, String)>, CustomLabelError>
pub fn read_custom_labels<P: AsRef<Path>>( path: P ) -> Result<Vec<(Hash40, String)>, CustomLabelError>
Opens a file and returns a list of line-separated pairs of hashes and labels. Each hash-label pair is separated by a comma, and the hash must be formatted in hexadecimal, beginning with “0x”
sourcepub fn add_labels_from_path<P: AsRef<Path>>(
&mut self,
path: P
) -> Result<(), Error>
pub fn add_labels_from_path<P: AsRef<Path>>( &mut self, path: P ) -> Result<(), Error>
A combination of the two functions Self::add_labels
and Self::read_labels
sourcepub fn add_custom_labels_from_path<P: AsRef<Path>>(
&mut self,
path: P
) -> Result<(), CustomLabelError>
pub fn add_custom_labels_from_path<P: AsRef<Path>>( &mut self, path: P ) -> Result<(), CustomLabelError>
A combination of the two functions Self::add_custom_labels
and
Self::read_custom_labels