Enum noodles::bam::record::data::field::Value [−][src]
pub enum Value {
Show 17 variants
Char(char),
Int8(i8),
UInt8(u8),
Int16(i16),
UInt16(u16),
Int32(i32),
UInt32(u32),
Float(f32),
String(String),
Hex(String),
Int8Array(Vec<i8, Global>),
UInt8Array(Vec<u8, Global>),
Int16Array(Vec<i16, Global>),
UInt16Array(Vec<u16, Global>),
Int32Array(Vec<i32, Global>),
UInt32Array(Vec<u32, Global>),
FloatArray(Vec<f32, Global>),
}
Expand description
A BAM record data field value.
BAM record data field values support all the same types as a SAM record data field value:
- character (
A
), - 32-bit integer (
i
), - single-precision floating-point (
f
), - string (
Z
), - hex string (
H
), - 8-bit integer array (
Bc
), - 8-bit unsigned integer array (
BC
), - 16-bit integer array (
Bs
), - 16-bit unsigned integer array (
BS
), - 32-bit integer array (
Bi
), - 32-bit unsigned integer array (
BI
), and - single-precision floating-point array (
Bf
),
Additionally, it is a superset of SAM record data field values, supporting additional single-value integer types:
- 8-bit integer (
c
), - 8-bit unsigned integer (
C
), - 16-bit integer (
s
), - 16-bit unsigned integer (
S
), and - 32-bit unsigned integer (
I
).
Variants
Char(char)
A character (A
).
Tuple Fields of Char
0: char
Int8(i8)
An 8-bit integer (c
).
Tuple Fields of Int8
0: i8
UInt8(u8)
An 8-bit unsigned integer (C
).
Tuple Fields of UInt8
0: u8
Int16(i16)
A 16-bit integer (s
).
Tuple Fields of Int16
0: i16
UInt16(u16)
A 16-bit unsigned integer (S
).
Tuple Fields of UInt16
0: u16
Int32(i32)
A 32-bit integer (i
).
Tuple Fields of Int32
0: i32
UInt32(u32)
A 32-bit unsigned integer (I
).
Tuple Fields of UInt32
0: u32
Float(f32)
A single-precision floating-point (f
).
Tuple Fields of Float
0: f32
String(String)
A string (Z
).
Tuple Fields of String
0: String
Hex(String)
A hex string (H
).
Tuple Fields of Hex
0: String
An 8-bit integer array (Bc
).
An 8-bit unsigned integer array (BC
).
A 16-bit integer array (Bs
).
A 16-bit unsigned integer array (BS
).
A 32-bit integer array (Bi
).
A 32-bit unsigned integer array (BI
).
A single-precision floating-point array (Bf
).
Implementations
Returns the type of the value.
Examples
use noodles_bam::record::data::field::{value::Type, Value};
assert_eq!(Value::Int32(0).ty(), Type::Int32);
Returns the subtype of the value.
Only arrays have subtypes.
Examples
use noodles_bam::record::data::field::{value::Subtype, Value};
assert_eq!(Value::UInt8Array(vec![0]).subtype(), Some(Subtype::UInt8));
assert_eq!(Value::Int32(0).subtype(), None);
Returns the value as a character if it is a character.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Char('a').as_char(), Some('a'));
assert_eq!(Value::Int32(0).as_char(), None);
Returns whether the value is a character.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Char('a').is_char());
assert!(!Value::Int32(0).is_char());
Returns the value as an 8-bit integer if it is an 8-bit integer.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int8(0).as_int8(), Some(0));
assert_eq!(Value::Int32(0).as_int8(), None);
Returns whether the value is an 8-bit integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int8(0).is_int8());
assert!(!Value::Int32(0).is_int8());
Returns the value as an 8-bit unsigned integer if it is an 8-bit unsigned integer.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::UInt8(0).as_uint8(), Some(0));
assert_eq!(Value::Int32(0).as_uint8(), None);
Returns whether the value is an 8-bit unsigned integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::UInt8(0).is_uint8());
assert!(!Value::Int32(0).is_uint8());
Returns the value as a 16-bit integer if it is a 16-bit integer.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int16(0).as_int16(), Some(0));
assert_eq!(Value::Int32(0).as_int16(), None);
Returns whether the value is a 16-bit integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int16(0).is_int16());
assert!(!Value::Int32(0).is_int16());
Returns the value as a 16-bit unsigned integer if it is a 16-bit unsigned integer.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::UInt16(0).as_uint16(), Some(0));
assert_eq!(Value::Int32(0).as_uint16(), None);
Returns whether the value is an 16-bit unsigned integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::UInt16(0).is_uint16());
assert!(!Value::Int32(0).is_uint16());
Returns the value as a 32-bit integer if it is a 32-bit integer.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int32(0).as_int32(), Some(0));
assert_eq!(Value::Char('a').as_int32(), None);
Returns whether the value is a 32-bit integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int32(0).is_int32());
assert!(!Value::Char('a').is_int32());
Returns the value as a 32-bit unsigned integer if it is a 32-bit unsigned integer.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::UInt32(0).as_uint32(), Some(0));
assert_eq!(Value::Int32(0).as_uint32(), None);
Returns whether the value is an 32-bit unsigned integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::UInt32(0).is_uint32());
assert!(!Value::Int32(0).is_uint32());
Returns the value as a 64-bit integer, if it is an integer.
This is a convenience method to convert any integer to an i64
, which captures the entire
range of all BAM record data field integer values.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int32(0).as_int(), Some(0));
assert_eq!(Value::Char('a').as_int(), None);
Returns whether the value is an integer.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int32(0).is_int());
assert!(!Value::Char('a').is_int());
Returns the value as a single-precision floating-point if it is a single-precision float-point.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Float(0.0).as_float(), Some(0.0));
assert_eq!(Value::Int32(0).as_float(), None);
Returns whether the value is a single-precision floating-point.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Float(0.0).is_float());
assert!(!Value::Int32(0).is_float());
Returns the value as a string slice if it is a string slice.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::String(String::from("noodles")).as_str(), Some("noodles"));
assert_eq!(Value::Int32(0).as_str(), None);
Returns whether the value is a string.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::String(String::from("noodles")).is_str());
assert!(!Value::Int32(0).is_str());
Returns the value as a string slice of hex if it is a string slice of hex.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Hex(String::from("cafe")).as_hex(), Some("cafe"));
assert_eq!(Value::Int32(0).as_hex(), None);
Returns whether the value is a hex string.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Hex(String::from("cafe")).is_hex());
assert!(!Value::Int32(0).is_hex());
Returns the value as an array of 8-bit integers if it is an array of 8-bit integers.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int8Array(vec![0]).as_int8_array(), Some(&[0][..]));
assert_eq!(Value::Int32(0).as_int8_array(), None);
Returns whether the value is an 8-bit integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int8Array(vec![0]).is_int8_array());
assert!(!Value::Int32(0).is_int8_array());
Returns the value as an array of 8-bit unsigned integers if it is an array of 8-bit unsigned integers.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::UInt8Array(vec![0]).as_uint8_array(), Some(&[0][..]));
assert_eq!(Value::Int32(0).as_uint8_array(), None);
Returns whether the value is an 8-bit unsigned integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::UInt8Array(vec![0]).is_uint8_array());
assert!(!Value::Int32(0).is_uint8_array());
Returns the value as an array of 16-bit integers if it is an array of 16-bit integers.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int16Array(vec![0]).as_int16_array(), Some(&[0][..]));
assert_eq!(Value::Int32(0).as_int16_array(), None);
Returns whether the value is a 16-bit integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int16Array(vec![0]).is_int16_array());
assert!(!Value::Int32(0).is_int16_array());
Returns the value as an array of 16-bit unsigned integers if it is an array of 16-bit unsigned integers.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::UInt16Array(vec![0]).as_uint16_array(), Some(&[0][..]));
assert_eq!(Value::Int32(0).as_uint16_array(), None);
Returns whether the value is a 16-bit unsigned integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::UInt16Array(vec![0]).is_uint16_array());
assert!(!Value::Int32(0).is_int16_array());
Returns the value as an array of 32-bit integers if it is an array of 32-bit integers.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::Int32Array(vec![0]).as_int32_array(), Some(&[0][..]));
assert_eq!(Value::Int32(0).as_int32_array(), None);
Returns whether the value is a 32-bit integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int32Array(vec![0]).is_int32_array());
assert!(!Value::Int32(0).is_int16_array());
Returns the value as an array of 32-bit unsigned integers if it is an array of 32-bit unsigned integers.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::UInt32Array(vec![0]).as_uint32_array(), Some(&[0][..]));
assert_eq!(Value::Int32(0).as_uint32_array(), None);
Returns whether the value is a 32-bit unsigned integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::UInt32Array(vec![0]).is_uint32_array());
assert!(!Value::Int32(0).is_int32_array());
Returns the value as an array of single-precision floating-points if it is an array of single-precision floating-points.
Examples
use noodles_bam::record::data::field::Value;
assert_eq!(Value::FloatArray(vec![0.0]).as_float_array(), Some(&[0.0][..]));
assert_eq!(Value::Int32(0).as_float_array(), None);
Returns whether the value is a 32-bit integer array.
Examples
use noodles_bam::record::data::field::Value;
assert!(Value::Int32Array(vec![0]).is_int32_array());
assert!(!Value::Int32(0).is_int16_array());
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Value
impl UnwindSafe for Value
Blanket Implementations
Mutably borrows from an owned value. Read more