Enum noodles_bam::record::data::field::value::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>), UInt8Array(Vec<u8>), Int16Array(Vec<i16>), UInt16Array(Vec<u16>), Int32Array(Vec<i32>), UInt32Array(Vec<u32>), FloatArray(Vec<f32>),
}
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)

Tuple Fields

0: char

A character (A).

Int8(i8)

Tuple Fields

0: i8

An 8-bit integer (c).

UInt8(u8)

Tuple Fields

0: u8

An 8-bit unsigned integer (C).

Int16(i16)

Tuple Fields

0: i16

A 16-bit integer (s).

UInt16(u16)

Tuple Fields

0: u16

A 16-bit unsigned integer (S).

Int32(i32)

Tuple Fields

0: i32

A 32-bit integer (i).

UInt32(u32)

Tuple Fields

0: u32

A 32-bit unsigned integer (I).

Float(f32)

Tuple Fields

0: f32

A single-precision floating-point (f).

String(String)

Tuple Fields

0: String

A string (Z).

Hex(String)

Tuple Fields

0: String

A hex string (H).

Int8Array(Vec<i8>)

Tuple Fields

0: Vec<i8>

An 8-bit integer array (Bc).

UInt8Array(Vec<u8>)

Tuple Fields

0: Vec<u8>

An 8-bit unsigned integer array (BC).

Int16Array(Vec<i16>)

Tuple Fields

0: Vec<i16>

A 16-bit integer array (Bs).

UInt16Array(Vec<u16>)

Tuple Fields

0: Vec<u16>

A 16-bit unsigned integer array (BS).

Int32Array(Vec<i32>)

Tuple Fields

0: Vec<i32>

A 32-bit integer array (Bi).

UInt32Array(Vec<u32>)

Tuple Fields

0: Vec<u32>

A 32-bit unsigned integer array (BI).

FloatArray(Vec<f32>)

Tuple Fields

0: Vec<f32>

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.