pub(crate) fn put(&self, buf: &mut Vec<u8>) {
        buf.push(self.ty as u8);

        match self.ty {
            DataType::Null
            | DataType::TinyInt
            | DataType::Bit
            | DataType::SmallInt
            | DataType::Int
            | DataType::SmallDateTime
            | DataType::Real
            | DataType::SmallMoney
            | DataType::BigInt
            | DataType::Money
            | DataType::DateTime
            | DataType::Float
            | DataType::DateN => {
                // nothing to do
            }

            DataType::TimeN | DataType::DateTime2N | DataType::DateTimeOffsetN => {
                buf.push(self.scale);
            }

            DataType::Guid
            | DataType::IntN
            | DataType::BitN
            | DataType::FloatN
            | DataType::MoneyN
            | DataType::DateTimeN
            | DataType::Char
            | DataType::VarChar
            | DataType::Binary
            | DataType::VarBinary => {
                buf.push(self.size as u8);
            }

            DataType::Decimal | DataType::Numeric | DataType::DecimalN | DataType::NumericN => {
                buf.push(self.size as u8);
                buf.push(self.precision);
                buf.push(self.scale);
            }

            DataType::BigVarBinary | DataType::BigBinary => {
                buf.extend(&(self.size as u16).to_le_bytes());
            }

            DataType::BigVarChar | DataType::BigChar | DataType::NVarChar | DataType::NChar => {
                buf.extend(&(self.size as u16).to_le_bytes());

                if let Some(collation) = &self.collation {
                    collation.put(buf);
                } else {
                    buf.extend(&0_u32.to_le_bytes());
                    buf.push(0);
                }
            }

            _ => {
                unimplemented!("unsupported data type {:?}", self.ty);
            }
        }
    }
// writes a TYPE_INFO to the buffer
writes a TYPE_INFO to the buffer
writes a TYPE_INFO to the buffer
pub(crate) fn put(&self, buf: &mut Vec<u8>) {
        buf.push(self.ty as u8);
        match self.ty {
            DataType::Null
            | DataType::TinyInt
            | DataType::Bit
            | DataType::SmallInt
            | DataType::Int
            | DataType::SmallDateTime
            | DataType::Real
            | DataType::SmallMoney
            | DataType::BigInt
            | DataType::Money
            | DataType::DateTime
            | DataType::Float
            | DataType::DateN => {
                // nothing to do
            }
            DataType::TimeN | DataType::DateTime2N | DataType::DateTimeOffsetN => {
                buf.push(self.scale);
            }
            DataType::Guid
            | DataType::IntN
            | DataType::BitN
            | DataType::FloatN
            | DataType::MoneyN
            | DataType::DateTimeN
            | DataType::Char
            | DataType::VarChar
            | DataType::Binary
            | DataType::VarBinary => {
                buf.push(self.size as u8);
            }
            DataType::Decimal | DataType::Numeric | DataType::DecimalN | DataType::NumericN => {
                buf.push(self.size as u8);
                buf.push(self.precision);
                buf.push(self.scale);
            }
            DataType::BigVarBinary | DataType::BigBinary => {
                buf.extend(&(self.size as u16).to_le_bytes());
            }
            DataType::BigVarChar | DataType::BigChar | DataType::NVarChar | DataType::NChar => {
                buf.extend(&(self.size as u16).to_le_bytes());
                if let Some(collation) = &self.collation {
                    collation.put(buf);
                } else {
                    buf.extend(&0_u32.to_le_bytes());
                    buf.push(0);
                }
            }
            _ => {
                unimplemented!("unsupported data type {:?}", self.ty);
            }
        }
    }
pub ( crate ) fn put ( & self , buf : & mut Vec < u8 > ) { buf . push ( self . ty as u8 ) ; match self . ty { DataType :: Null | DataType :: TinyInt | DataType :: Bit | DataType :: SmallInt | DataType :: Int | DataType :: SmallDateTime | DataType :: Real | DataType :: SmallMoney | DataType :: BigInt | DataType :: Money | DataType :: DateTime | DataType :: Float | DataType :: DateN => { // nothing to do } DataType :: TimeN | DataType :: DateTime2N | DataType :: DateTimeOffsetN => { buf . push ( self . scale ) ; } DataType :: Guid | DataType :: IntN | DataType :: BitN | DataType :: FloatN | DataType :: MoneyN | DataType :: DateTimeN | DataType :: Char | DataType :: VarChar | DataType :: Binary | DataType :: VarBinary => { buf . push ( self . size as u8 ) ; } DataType :: Decimal | DataType :: Numeric | DataType :: DecimalN | DataType :: NumericN => { buf . push ( self . size as u8 ) ; buf . push ( self . precision ) ; buf . push ( self . scale ) ; } DataType :: BigVarBinary | DataType :: BigBinary => { buf . extend ( & ( self . size as u16 ) . to_le_bytes ( ) ) ; } DataType :: BigVarChar | DataType :: BigChar | DataType :: NVarChar | DataType :: NChar => { buf . extend ( & ( self . size as u16 ) . to_le_bytes ( ) ) ; if let Some ( collation ) = & self . collation { collation . put ( buf ) ; } else { buf . extend ( & 0_u32 . to_le_bytes ( ) ) ; buf . push ( 0 ) ; } } _ => { unimplemented ! ( " " self ty ) ; } } }
writes a TYPE_INFO to the buffer
writes a TYPE_INFO to the buffer
&self
buf
&mut Vec<u8>
&self
buf
&mut Vec<u8>