Struct noodles_vcf::variant::record_buf::info::Info
source · pub struct Info(/* private fields */);
Expand description
A variant record record info fields buffer.
Implementations§
source§impl Info
impl Info
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all fields from the info map.
This does not affect the capacity of the map.
§Examples
use noodles_vcf::variant::{
record::{info::field::key, Info as _},
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let mut info: Info = [ns, dp].into_iter().collect();
assert!(!info.is_empty());
info.clear();
assert!(info.is_empty());
sourcepub fn get<K>(&self, key: &K) -> Option<Option<&Value>>
pub fn get<K>(&self, key: &K) -> Option<Option<&Value>>
Returns a reference to the field value with the given key.
§Examples
use noodles_vcf::variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let info: Info = [ns, dp.clone()].into_iter().collect();
assert_eq!(info.get(key::TOTAL_DEPTH), Some(Some(&Value::Integer(13))));
assert!(info.get(key::ALLELE_FREQUENCIES).is_none());
sourcepub fn get_mut<K>(&mut self, key: &K) -> Option<&mut Option<Value>>
pub fn get_mut<K>(&mut self, key: &K) -> Option<&mut Option<Value>>
Returns a mutable reference to the field value with the given key.
§Examples
use noodles_vcf::variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let mut info: Info = [ns, dp].into_iter().collect();
if let Some(value) = info.get_mut(key::TOTAL_DEPTH) {
*value = Some(Value::Integer(8));
}
assert_eq!(info.get(key::TOTAL_DEPTH), Some(Some(&Value::Integer(8))));
sourcepub fn get_index(&self, i: usize) -> Option<(&String, Option<&Value>)>
pub fn get_index(&self, i: usize) -> Option<(&String, Option<&Value>)>
Returns a reference to the field at the given index.
§Examples
use noodles_vcf::variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let info: Info = [ns, dp].into_iter().collect();
assert_eq!(
info.get_index(1),
Some((&String::from(key::TOTAL_DEPTH), Some(&Value::Integer(13))))
);
assert!(info.get_index(5).is_none());
sourcepub fn get_index_mut(
&mut self,
i: usize,
) -> Option<(&String, &mut Option<Value>)>
pub fn get_index_mut( &mut self, i: usize, ) -> Option<(&String, &mut Option<Value>)>
Returns a mutable reference to the field at the given index.
§Examples
use noodles_vcf::variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let mut info: Info = [ns, dp].into_iter().collect();
if let Some((_, value)) = info.get_index_mut(1) {
*value = Some(Value::Integer(8));
}
assert_eq!(
info.get_index(1),
Some((&String::from(key::TOTAL_DEPTH), Some(&Value::Integer(8))))
);
sourcepub fn insert(
&mut self,
key: String,
value: Option<Value>,
) -> Option<Option<Value>>
pub fn insert( &mut self, key: String, value: Option<Value>, ) -> Option<Option<Value>>
Inserts a field into the info map.
If the key already exists in the map, the existing value is replaced by the new one, and the existing value is returned.
§Examples
use noodles_vcf::variant::{
record::{info::field::key, Info as _},
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let mut info: Info = [ns].into_iter().collect();
assert_eq!(info.len(), 1);
info.insert(String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
assert_eq!(info.len(), 2);
assert_eq!(info.get(key::TOTAL_DEPTH), Some(Some(&Value::Integer(13))));
sourcepub fn keys(&self) -> impl Iterator<Item = &String>
pub fn keys(&self) -> impl Iterator<Item = &String>
Returns an iterator over all keys.
§Examples
use noodles_vcf::variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let info: Info = [ns, dp].into_iter().collect();
let mut keys = info.keys();
assert_eq!(keys.next(), Some(&String::from(key::SAMPLES_WITH_DATA_COUNT)));
assert_eq!(keys.next(), Some(&String::from(key::TOTAL_DEPTH)));
assert!(keys.next().is_none());
sourcepub fn values(&self) -> impl Iterator<Item = Option<&Value>>
pub fn values(&self) -> impl Iterator<Item = Option<&Value>>
Returns an iterator over all values.
§Examples
use noodles_vcf::variant::{
record::info::field::key,
record_buf::{info::field::Value, Info},
};
let ns = (String::from(key::SAMPLES_WITH_DATA_COUNT), Some(Value::Integer(2)));
let dp = (String::from(key::TOTAL_DEPTH), Some(Value::Integer(13)));
let info: Info = [ns, dp].into_iter().collect();
let mut values = info.values();
assert_eq!(values.next(), Some(Some(&Value::Integer(2))));
assert_eq!(values.next(), Some(Some(&Value::Integer(13))));
assert!(values.next().is_none());
Trait Implementations§
source§impl Extend<(String, Option<Value>)> for Info
impl Extend<(String, Option<Value>)> for Info
source§fn extend<T: IntoIterator<Item = (String, Option<Value>)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (String, Option<Value>)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl Info for &Info
impl Info for &Info
source§impl Info for Info
impl Info for Info
source§impl PartialEq for Info
impl PartialEq for Info
impl StructuralPartialEq for Info
Auto Trait Implementations§
impl Freeze for Info
impl RefUnwindSafe for Info
impl Send for Info
impl Sync for Info
impl Unpin for Info
impl UnwindSafe for Info
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