fn bit_width(data_type: &DataType, i: usize) -> Result<usize> {
    Ok(match (data_type, i) {
        // the null buffer is bit sized
        (_, 0) => 1,
        // primitive types first buffer's size is given by the native types
        (DataType::Boolean, 1) => 1,
        (DataType::UInt8, 1) => size_of::<u8>() * 8,
        (DataType::UInt16, 1) => size_of::<u16>() * 8,
        (DataType::UInt32, 1) => size_of::<u32>() * 8,
        (DataType::UInt64, 1) => size_of::<u64>() * 8,
        (DataType::Int8, 1) => size_of::<i8>() * 8,
        (DataType::Int16, 1) => size_of::<i16>() * 8,
        (DataType::Int32, 1) | (DataType::Date32, 1) | (DataType::Time32(_), 1) => size_of::<i32>() * 8,
        (DataType::Int64, 1) | (DataType::Date64, 1) | (DataType::Time64(_), 1) => size_of::<i64>() * 8,
        (DataType::Float32, 1) => size_of::<f32>() * 8,
        (DataType::Float64, 1) => size_of::<f64>() * 8,
        // primitive types have a single buffer
        (DataType::Boolean, _) |
        (DataType::UInt8, _) |
        (DataType::UInt16, _) |
        (DataType::UInt32, _) |
        (DataType::UInt64, _) |
        (DataType::Int8, _) |
        (DataType::Int16, _) |
        (DataType::Int32, _) | (DataType::Date32, _) | (DataType::Time32(_), _) |
        (DataType::Int64, _) | (DataType::Date64, _) | (DataType::Time64(_), _) |
        (DataType::Float32, _) |
        (DataType::Float64, _) => {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" expects 2 buffers, but requested {}. Please verify that the C data interface is correctly implemented.",
                data_type, i
            )))
        }
        // Variable-sized binaries: have two buffers.
        // "small": first buffer is i32, second is in bytes
        (DataType::Utf8, 1) | (DataType::Binary, 1) | (DataType::List(_), 1) => size_of::<i32>() * 8,
        (DataType::Utf8, 2) | (DataType::Binary, 2) | (DataType::List(_), 2) => size_of::<u8>() * 8,
        (DataType::Utf8, _) | (DataType::Binary, _) | (DataType::List(_), _)=> {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" expects 3 buffers, but requested {}. Please verify that the C data interface is correctly implemented.",
                data_type, i
            )))
        }
        // Variable-sized binaries: have two buffers.
        // LargeUtf8: first buffer is i64, second is in bytes
        (DataType::LargeUtf8, 1) | (DataType::LargeBinary, 1) | (DataType::LargeList(_), 1) => size_of::<i64>() * 8,
        (DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) | (DataType::LargeList(_), 2)=> size_of::<u8>() * 8,
        (DataType::LargeUtf8, _) | (DataType::LargeBinary, _) | (DataType::LargeList(_), _)=> {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" expects 3 buffers, but requested {}. Please verify that the C data interface is correctly implemented.",
                data_type, i
            )))
        }
        _ => {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" is still not supported in Rust implementation",
                data_type
            )))
        }
    })
}
// returns the number of bits that buffer `i` (in the C data interface) is expected to have.
// This is set by the Arrow specification
returns the number of bits that buffer `i` (in the C data interface) is expected to have.
This is set by the Arrow specification
returns the number of bits that buffer ` i ` ( in the C data interface ) is expected to have . This is set by the Arrow specification
fn bit_width(data_type: &DataType, i: usize) -> Result<usize> {
    Ok(match (data_type, i) {
        // the null buffer is bit sized
        (_, 0) => 1,
        // primitive types first buffer's size is given by the native types
        (DataType::Boolean, 1) => 1,
        (DataType::UInt8, 1) => size_of::<u8>() * 8,
        (DataType::UInt16, 1) => size_of::<u16>() * 8,
        (DataType::UInt32, 1) => size_of::<u32>() * 8,
        (DataType::UInt64, 1) => size_of::<u64>() * 8,
        (DataType::Int8, 1) => size_of::<i8>() * 8,
        (DataType::Int16, 1) => size_of::<i16>() * 8,
        (DataType::Int32, 1) | (DataType::Date32, 1) | (DataType::Time32(_), 1) => size_of::<i32>() * 8,
        (DataType::Int64, 1) | (DataType::Date64, 1) | (DataType::Time64(_), 1) => size_of::<i64>() * 8,
        (DataType::Float32, 1) => size_of::<f32>() * 8,
        (DataType::Float64, 1) => size_of::<f64>() * 8,
        // primitive types have a single buffer
        (DataType::Boolean, _) |
        (DataType::UInt8, _) |
        (DataType::UInt16, _) |
        (DataType::UInt32, _) |
        (DataType::UInt64, _) |
        (DataType::Int8, _) |
        (DataType::Int16, _) |
        (DataType::Int32, _) | (DataType::Date32, _) | (DataType::Time32(_), _) |
        (DataType::Int64, _) | (DataType::Date64, _) | (DataType::Time64(_), _) |
        (DataType::Float32, _) |
        (DataType::Float64, _) => {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" expects 2 buffers, but requested {}. Please verify that the C data interface is correctly implemented.",
                data_type, i
            )))
        }
        // Variable-sized binaries: have two buffers.
        // "small": first buffer is i32, second is in bytes
        (DataType::Utf8, 1) | (DataType::Binary, 1) | (DataType::List(_), 1) => size_of::<i32>() * 8,
        (DataType::Utf8, 2) | (DataType::Binary, 2) | (DataType::List(_), 2) => size_of::<u8>() * 8,
        (DataType::Utf8, _) | (DataType::Binary, _) | (DataType::List(_), _)=> {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" expects 3 buffers, but requested {}. Please verify that the C data interface is correctly implemented.",
                data_type, i
            )))
        }
        // Variable-sized binaries: have two buffers.
        // LargeUtf8: first buffer is i64, second is in bytes
        (DataType::LargeUtf8, 1) | (DataType::LargeBinary, 1) | (DataType::LargeList(_), 1) => size_of::<i64>() * 8,
        (DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) | (DataType::LargeList(_), 2)=> size_of::<u8>() * 8,
        (DataType::LargeUtf8, _) | (DataType::LargeBinary, _) | (DataType::LargeList(_), _)=> {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" expects 3 buffers, but requested {}. Please verify that the C data interface is correctly implemented.",
                data_type, i
            )))
        }
        _ => {
            return Err(ArrowError::CDataInterface(format!(
                "The datatype \"{:?}\" is still not supported in Rust implementation",
                data_type
            )))
        }
    })
}
fn bit_width ( data_type : & DataType , i : usize ) -> Result < usize > { Ok ( match ( data_type , i ) { // the null buffer is bit sized ( _ , 0 ) => 1 , // primitive types first buffer's size is given by the native types ( DataType :: Boolean , 1 ) => 1 , ( DataType :: UInt8 , 1 ) => size_of :: < u8 > ( ) * 8 , ( DataType :: UInt16 , 1 ) => size_of :: < u16 > ( ) * 8 , ( DataType :: UInt32 , 1 ) => size_of :: < u32 > ( ) * 8 , ( DataType :: UInt64 , 1 ) => size_of :: < u64 > ( ) * 8 , ( DataType :: Int8 , 1 ) => size_of :: < i8 > ( ) * 8 , ( DataType :: Int16 , 1 ) => size_of :: < i16 > ( ) * 8 , ( DataType :: Int32 , 1 ) | ( DataType :: Date32 , 1 ) | ( DataType :: Time32 ( _ ) , 1 ) => size_of :: < i32 > ( ) * 8 , ( DataType :: Int64 , 1 ) | ( DataType :: Date64 , 1 ) | ( DataType :: Time64 ( _ ) , 1 ) => size_of :: < i64 > ( ) * 8 , ( DataType :: Float32 , 1 ) => size_of :: < f32 > ( ) * 8 , ( DataType :: Float64 , 1 ) => size_of :: < f64 > ( ) * 8 , // primitive types have a single buffer ( DataType :: Boolean , _ ) | ( DataType :: UInt8 , _ ) | ( DataType :: UInt16 , _ ) | ( DataType :: UInt32 , _ ) | ( DataType :: UInt64 , _ ) | ( DataType :: Int8 , _ ) | ( DataType :: Int16 , _ ) | ( DataType :: Int32 , _ ) | ( DataType :: Date32 , _ ) | ( DataType :: Time32 ( _ ) , _ ) | ( DataType :: Int64 , _ ) | ( DataType :: Date64 , _ ) | ( DataType :: Time64 ( _ ) , _ ) | ( DataType :: Float32 , _ ) | ( DataType :: Float64 , _ ) => { return Err ( ArrowError :: CDataInterface ( format ! ( " \" \" " data_type i ) ) ) } // Variable-sized binaries: have two buffers. // "small": first buffer is i32, second is in bytes ( DataType :: Utf8 , 1 ) | ( DataType :: Binary , 1 ) | ( DataType :: List ( _ ) , 1 ) => size_of :: < i32 > ( ) * 8 , ( DataType :: Utf8 , 2 ) | ( DataType :: Binary , 2 ) | ( DataType :: List ( _ ) , 2 ) => size_of :: < u8 > ( ) * 8 , ( DataType :: Utf8 , _ ) | ( DataType :: Binary , _ ) | ( DataType :: List ( _ ) , _ ) => { return Err ( ArrowError :: CDataInterface ( format ! ( " \" \" " data_type i ) ) ) } // Variable-sized binaries: have two buffers. // LargeUtf8: first buffer is i64, second is in bytes ( DataType :: LargeUtf8 , 1 ) | ( DataType :: LargeBinary , 1 ) | ( DataType :: LargeList ( _ ) , 1 ) => size_of :: < i64 > ( ) * 8 , ( DataType :: LargeUtf8 , 2 ) | ( DataType :: LargeBinary , 2 ) | ( DataType :: LargeList ( _ ) , 2 ) => size_of :: < u8 > ( ) * 8 , ( DataType :: LargeUtf8 , _ ) | ( DataType :: LargeBinary , _ ) | ( DataType :: LargeList ( _ ) , _ ) => { return Err ( ArrowError :: CDataInterface ( format ! ( " \" \" " data_type i ) ) ) } _ => { return Err ( ArrowError :: CDataInterface ( format ! ( " \" \" " data_type ) ) ) } } ) }
returns the number of bits that buffer `i` (in the C data interface) is expected to have.
returns the number of bits that buffer ` i ` ( in the C data interface ) is expected to have .
data_type
&DataType
i
usize
data_type
&DataType
i
usize