pub fn read_value<R>(reader: &mut R, ty: Type) -> io::Result<Value>
where
    R: BufRead,
{
    match ty {
        Type::Char => reader.read_u8().map(char::from).map(Value::Char),
        Type::Int8 => reader.read_i8().map(Value::Int8),
        Type::UInt8 => reader.read_u8().map(Value::UInt8),
        Type::Int16 => reader.read_i16::<LittleEndian>().map(Value::Int16),
        Type::UInt16 => reader.read_u16::<LittleEndian>().map(Value::UInt16),
        Type::Int32 => reader.read_i32::<LittleEndian>().map(Value::Int32),
        Type::UInt32 => reader.read_u32::<LittleEndian>().map(Value::UInt32),
        Type::Float => reader.read_f32::<LittleEndian>().map(Value::Float),
        Type::String => read_string(reader).map(Value::String),
        Type::Hex => read_string(reader).map(Value::Hex),
        Type::Array => read_array(reader),
    }
}
/// Reads a BAM record data field value.
///
/// The stream is expected to be at the start of the value, i.e., after the tag and data type.
///
/// # Examples
///
/// ```
/// # use std::io;
/// use noodles_bam::{
///     reader::record::data::field::read_value,
///     record::data::field::{value::Type, Value}
/// };
///
/// let data = [0x01, 0x00, 0x00, 0x00];
/// let mut reader = &data[..];
///
/// assert_eq!(
///     read_value(&mut reader, Type::Int32)?,
///     Value::Int32(1)
/// );
/// # Ok::<(), io::Error>(())
/// ```
Reads a BAM record data field value.
The stream is expected to be at the start of the value, i.e., after the tag and data type.
Reads a BAM record data field value . The stream is expected to be at the start of the value i . e . after the tag and data type .
pub fn read_value<R>(reader: &mut R, ty: Type) -> io::Result<Value>
where
    R: BufRead,
{
    match ty {
        Type::Char => reader.read_u8().map(char::from).map(Value::Char),
        Type::Int8 => reader.read_i8().map(Value::Int8),
        Type::UInt8 => reader.read_u8().map(Value::UInt8),
        Type::Int16 => reader.read_i16::<LittleEndian>().map(Value::Int16),
        Type::UInt16 => reader.read_u16::<LittleEndian>().map(Value::UInt16),
        Type::Int32 => reader.read_i32::<LittleEndian>().map(Value::Int32),
        Type::UInt32 => reader.read_u32::<LittleEndian>().map(Value::UInt32),
        Type::Float => reader.read_f32::<LittleEndian>().map(Value::Float),
        Type::String => read_string(reader).map(Value::String),
        Type::Hex => read_string(reader).map(Value::Hex),
        Type::Array => read_array(reader),
    }
}
pub fn read_value < R > ( reader : & mut R , ty : Type ) -> io :: Result < Value > where R : BufRead , { match ty { Type :: Char => reader . read_u8 ( ) . map ( char :: from ) . map ( Value :: Char ) , Type :: Int8 => reader . read_i8 ( ) . map ( Value :: Int8 ) , Type :: UInt8 => reader . read_u8 ( ) . map ( Value :: UInt8 ) , Type :: Int16 => reader . read_i16 :: < LittleEndian > ( ) . map ( Value :: Int16 ) , Type :: UInt16 => reader . read_u16 :: < LittleEndian > ( ) . map ( Value :: UInt16 ) , Type :: Int32 => reader . read_i32 :: < LittleEndian > ( ) . map ( Value :: Int32 ) , Type :: UInt32 => reader . read_u32 :: < LittleEndian > ( ) . map ( Value :: UInt32 ) , Type :: Float => reader . read_f32 :: < LittleEndian > ( ) . map ( Value :: Float ) , Type :: String => read_string ( reader ) . map ( Value :: String ) , Type :: Hex => read_string ( reader ) . map ( Value :: Hex ) , Type :: Array => read_array ( reader ) , } }
Reads a BAM record data field value.
Reads a BAM record data field value .
reader
&mut R
ty
Type
reader
&mut R
ty
Type
examples
None
use std::io;
use noodles_bam::{
reader::record::data::field::read_value,
record::data::field::{value::Type, Value}
}.




use noodles_bam :: { reader :: record :: data :: field :: read_value record :: data :: field :: { value :: Type Value } } .
ok::<(), io::error>(())
None