pub struct Tags { /* private fields */ }
Expand description
A map from string keys to string values. This makes copies of strings for convenience; don’t use in performance sensitive contexts.
Implementations§
Source§impl Tags
impl Tags
Sourcepub fn from_pairs<I, K, V>(tags: I) -> Result<Self, DuplicateKeyError>
pub fn from_pairs<I, K, V>(tags: I) -> Result<Self, DuplicateKeyError>
Sourcepub fn to_str_pairs(&self) -> Vec<(&str, &str)>
pub fn to_str_pairs(&self) -> Vec<(&str, &str)>
Expose data as vector of pairs
Sourcepub fn is<Q>(&self, q: &Q, v: &str) -> bool
pub fn is<Q>(&self, q: &Q, v: &str) -> bool
Return if tags key has value, return false if key does not exist.
Sourcepub fn is_any<Q>(&self, q: &Q, values: &[&str]) -> bool
pub fn is_any<Q>(&self, q: &Q, values: &[&str]) -> bool
Return if tags key has any of the values, return false if the key does not exist.
Sourcepub fn checked_insert<K: Into<TagKey>, V: Into<TagVal>>(
&mut self,
key: K,
val: V,
) -> Result<(), DuplicateKeyError>
pub fn checked_insert<K: Into<TagKey>, V: Into<TagVal>>( &mut self, key: K, val: V, ) -> Result<(), DuplicateKeyError>
§Errors
If duplicate key is inserted.
Trait Implementations§
Source§impl FromStr for Tags
impl FromStr for Tags
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse ‘=’ separated tag pairs from a newline separated list.
use std::str::FromStr;
use osm_tags::Tags;
let tags = Tags::from_str("foo=bar\nabra=cadabra").unwrap();
assert_eq!(tags.get("foo"), Some("bar"));
Source§type Err = ParseTagsError
type Err = ParseTagsError
The associated error which can be returned from parsing.
Auto Trait Implementations§
impl Freeze for Tags
impl RefUnwindSafe for Tags
impl Send for Tags
impl Sync for Tags
impl Unpin for Tags
impl UnwindSafe for Tags
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more