pub fn into_datum<'a>(self, buf: &'a RowArena, typ: &Type) -> (Datum<'a>, ScalarType) {
        match self {
            Value::Array { .. } => {
                // This situation is handled gracefully by Value::decode; if we
                // wind up here it's a programming error.
                unreachable!("into_datum cannot be called on Value::Array");
            }
            Value::Bool(true) => (Datum::True, ScalarType::Bool),
            Value::Bool(false) => (Datum::False, ScalarType::Bool),
            Value::Bytea(b) => (Datum::Bytes(buf.push_bytes(b)), ScalarType::Bytes),
            Value::Date(d) => (Datum::Date(d), ScalarType::Date),
            Value::Float4(f) => (Datum::Float32(f.into()), ScalarType::Float32),
            Value::Float8(f) => (Datum::Float64(f.into()), ScalarType::Float64),
            Value::Int2(i) => (Datum::Int16(i), ScalarType::Int16),
            Value::Int4(i) => match typ {
                Type::Oid => (Datum::Int32(i), ScalarType::Int32),
                Type::Int4 => (Datum::Int32(i), ScalarType::Int32),
                _ => unreachable!(),
            },
            Value::Int8(i) => (Datum::Int64(i), ScalarType::Int64),
            Value::Jsonb(js) => (buf.push_unary_row(js.0.into_row()), ScalarType::Jsonb),
            Value::List(elems) => {
                let elem_pg_type = match typ {
                    Type::List(t) => &*t,
                    _ => panic!("Value::List should have type Type::List. Found {:?}", typ),
                };
                let (_, elem_type) = null_datum(&elem_pg_type);
                let mut row = Row::default();
                row.push_list(elems.into_iter().map(|elem| match elem {
                    Some(elem) => elem.into_datum(buf, &elem_pg_type).0,
                    None => Datum::Null,
                }));
                (
                    buf.push_unary_row(row),
                    ScalarType::List {
                        element_type: Box::new(elem_type),
                        custom_oid: None,
                    },
                )
            }
            Value::Map(map) => {
                let elem_pg_type = match typ {
                    Type::Map { value_type } => &*value_type,
                    _ => panic!("Value::Map should have type Type::Map. Found {:?}", typ),
                };
                let (_, elem_type) = null_datum(&elem_pg_type);
                let mut row = Row::default();
                row.push_dict_with(|row| {
                    for (k, v) in map {
                        row.push(Datum::String(&k));
                        row.push(match v {
                            Some(elem) => elem.into_datum(buf, &elem_pg_type).0,
                            None => Datum::Null,
                        });
                    }
                });
                (
                    buf.push_unary_row(row),
                    ScalarType::Map {
                        value_type: Box::new(elem_type),
                        custom_oid: None,
                    },
                )
            }
            Value::Record(_) => {
                // This situation is handled gracefully by Value::decode; if we
                // wind up here it's a programming error.
                unreachable!("into_datum cannot be called on Value::Record");
            }
            Value::Time(t) => (Datum::Time(t), ScalarType::Time),
            Value::Timestamp(ts) => (Datum::Timestamp(ts), ScalarType::Timestamp),
            Value::TimestampTz(ts) => (Datum::TimestampTz(ts), ScalarType::TimestampTz),
            Value::Interval(iv) => (Datum::Interval(iv.0), ScalarType::Interval),
            Value::Text(s) => (Datum::String(buf.push_string(s)), ScalarType::String),
            Value::Char { inner, length } => (
                Datum::String(buf.push_string(inner)),
                ScalarType::Char { length },
            ),
            Value::VarChar(s) => (
                Datum::String(buf.push_string(s)),
                ScalarType::VarChar { length: None },
            ),
            Value::Uuid(u) => (Datum::Uuid(u), ScalarType::Uuid),
            Value::Numeric(n) => (
                Datum::Numeric(n.0),
                ScalarType::Numeric {
                    scale: Some(adt_numeric::get_scale(&n.0 .0)),
                },
            ),
        }
    }
/// Converts a Materialize datum and type from this value.
///
/// To construct a null datum, see the [`null_datum`] function.
Converts a Materialize datum and type from this value.
To construct a null datum, see the [`null_datum`] function.
Converts a Materialize datum and type from this value . To construct a null datum see the [ ` null_datum ` ] function .
pub fn into_datum<'a>(self, buf: &'a RowArena, typ: &Type) -> (Datum<'a>, ScalarType) {
        match self {
            Value::Array { .. } => {
                // This situation is handled gracefully by Value::decode; if we
                // wind up here it's a programming error.
                unreachable!("into_datum cannot be called on Value::Array");
            }
            Value::Bool(true) => (Datum::True, ScalarType::Bool),
            Value::Bool(false) => (Datum::False, ScalarType::Bool),
            Value::Bytea(b) => (Datum::Bytes(buf.push_bytes(b)), ScalarType::Bytes),
            Value::Date(d) => (Datum::Date(d), ScalarType::Date),
            Value::Float4(f) => (Datum::Float32(f.into()), ScalarType::Float32),
            Value::Float8(f) => (Datum::Float64(f.into()), ScalarType::Float64),
            Value::Int2(i) => (Datum::Int16(i), ScalarType::Int16),
            Value::Int4(i) => match typ {
                Type::Oid => (Datum::Int32(i), ScalarType::Int32),
                Type::Int4 => (Datum::Int32(i), ScalarType::Int32),
                _ => unreachable!(),
            },
            Value::Int8(i) => (Datum::Int64(i), ScalarType::Int64),
            Value::Jsonb(js) => (buf.push_unary_row(js.0.into_row()), ScalarType::Jsonb),
            Value::List(elems) => {
                let elem_pg_type = match typ {
                    Type::List(t) => &*t,
                    _ => panic!("Value::List should have type Type::List. Found {:?}", typ),
                };
                let (_, elem_type) = null_datum(&elem_pg_type);
                let mut row = Row::default();
                row.push_list(elems.into_iter().map(|elem| match elem {
                    Some(elem) => elem.into_datum(buf, &elem_pg_type).0,
                    None => Datum::Null,
                }));
                (
                    buf.push_unary_row(row),
                    ScalarType::List {
                        element_type: Box::new(elem_type),
                        custom_oid: None,
                    },
                )
            }
            Value::Map(map) => {
                let elem_pg_type = match typ {
                    Type::Map { value_type } => &*value_type,
                    _ => panic!("Value::Map should have type Type::Map. Found {:?}", typ),
                };
                let (_, elem_type) = null_datum(&elem_pg_type);
                let mut row = Row::default();
                row.push_dict_with(|row| {
                    for (k, v) in map {
                        row.push(Datum::String(&k));
                        row.push(match v {
                            Some(elem) => elem.into_datum(buf, &elem_pg_type).0,
                            None => Datum::Null,
                        });
                    }
                });
                (
                    buf.push_unary_row(row),
                    ScalarType::Map {
                        value_type: Box::new(elem_type),
                        custom_oid: None,
                    },
                )
            }
            Value::Record(_) => {
                // This situation is handled gracefully by Value::decode; if we
                // wind up here it's a programming error.
                unreachable!("into_datum cannot be called on Value::Record");
            }
            Value::Time(t) => (Datum::Time(t), ScalarType::Time),
            Value::Timestamp(ts) => (Datum::Timestamp(ts), ScalarType::Timestamp),
            Value::TimestampTz(ts) => (Datum::TimestampTz(ts), ScalarType::TimestampTz),
            Value::Interval(iv) => (Datum::Interval(iv.0), ScalarType::Interval),
            Value::Text(s) => (Datum::String(buf.push_string(s)), ScalarType::String),
            Value::Char { inner, length } => (
                Datum::String(buf.push_string(inner)),
                ScalarType::Char { length },
            ),
            Value::VarChar(s) => (
                Datum::String(buf.push_string(s)),
                ScalarType::VarChar { length: None },
            ),
            Value::Uuid(u) => (Datum::Uuid(u), ScalarType::Uuid),
            Value::Numeric(n) => (
                Datum::Numeric(n.0),
                ScalarType::Numeric {
                    scale: Some(adt_numeric::get_scale(&n.0 .0)),
                },
            ),
        }
    }
pub fn into_datum < ' a > ( self , buf : & ' a RowArena , typ : & Type ) -> ( Datum < ' a > , ScalarType ) { match self { Value :: Array { .. } => { // This situation is handled gracefully by Value::decode; if we // wind up here it's a programming error. unreachable ! ( " " ) ; } Value :: Bool ( true ) => ( Datum :: True , ScalarType :: Bool ) , Value :: Bool ( false ) => ( Datum :: False , ScalarType :: Bool ) , Value :: Bytea ( b ) => ( Datum :: Bytes ( buf . push_bytes ( b ) ) , ScalarType :: Bytes ) , Value :: Date ( d ) => ( Datum :: Date ( d ) , ScalarType :: Date ) , Value :: Float4 ( f ) => ( Datum :: Float32 ( f . into ( ) ) , ScalarType :: Float32 ) , Value :: Float8 ( f ) => ( Datum :: Float64 ( f . into ( ) ) , ScalarType :: Float64 ) , Value :: Int2 ( i ) => ( Datum :: Int16 ( i ) , ScalarType :: Int16 ) , Value :: Int4 ( i ) => match typ { Type :: Oid => ( Datum :: Int32 ( i ) , ScalarType :: Int32 ) , Type :: Int4 => ( Datum :: Int32 ( i ) , ScalarType :: Int32 ) , _ => unreachable ! ( ) , } , Value :: Int8 ( i ) => ( Datum :: Int64 ( i ) , ScalarType :: Int64 ) , Value :: Jsonb ( js ) => ( buf . push_unary_row ( js . 0 . into_row ( ) ) , ScalarType :: Jsonb ) , Value :: List ( elems ) => { let elem_pg_type = match typ { Type :: List ( t ) => & * t , _ => panic ! ( " " typ ) , } ; let ( _ , elem_type ) = null_datum ( & elem_pg_type ) ; let mut row = Row :: default ( ) ; row . push_list ( elems . into_iter ( ) . map ( | elem | match elem { Some ( elem ) => elem . into_datum ( buf , & elem_pg_type ) . 0 , None => Datum :: Null , } ) ) ; ( buf . push_unary_row ( row ) , ScalarType :: List { element_type : Box :: new ( elem_type ) , custom_oid : None , } , ) } Value :: Map ( map ) => { let elem_pg_type = match typ { Type :: Map { value_type } => & * value_type , _ => panic ! ( " " typ ) , } ; let ( _ , elem_type ) = null_datum ( & elem_pg_type ) ; let mut row = Row :: default ( ) ; row . push_dict_with ( | row | { for ( k , v ) in map { row . push ( Datum :: String ( & k ) ) ; row . push ( match v { Some ( elem ) => elem . into_datum ( buf , & elem_pg_type ) . 0 , None => Datum :: Null , } ) ; } } ) ; ( buf . push_unary_row ( row ) , ScalarType :: Map { value_type : Box :: new ( elem_type ) , custom_oid : None , } , ) } Value :: Record ( _ ) => { // This situation is handled gracefully by Value::decode; if we // wind up here it's a programming error. unreachable ! ( " " ) ; } Value :: Time ( t ) => ( Datum :: Time ( t ) , ScalarType :: Time ) , Value :: Timestamp ( ts ) => ( Datum :: Timestamp ( ts ) , ScalarType :: Timestamp ) , Value :: TimestampTz ( ts ) => ( Datum :: TimestampTz ( ts ) , ScalarType :: TimestampTz ) , Value :: Interval ( iv ) => ( Datum :: Interval ( iv . 0 ) , ScalarType :: Interval ) , Value :: Text ( s ) => ( Datum :: String ( buf . push_string ( s ) ) , ScalarType :: String ) , Value :: Char { inner , length } => ( Datum :: String ( buf . push_string ( inner ) ) , ScalarType :: Char { length } , ) , Value :: VarChar ( s ) => ( Datum :: String ( buf . push_string ( s ) ) , ScalarType :: VarChar { length : None } , ) , Value :: Uuid ( u ) => ( Datum :: Uuid ( u ) , ScalarType :: Uuid ) , Value :: Numeric ( n ) => ( Datum :: Numeric ( n . 0 ) , ScalarType :: Numeric { scale : Some ( adt_numeric :: get_scale ( & n . 0 . 0 ) ) , } , ) , } }
Converts a Materialize datum and type from this value.
Converts a Materialize datum and type from this value .
self
buf
&'a RowArena
typ
&Type
self
buf
&'a RowArena
typ
&Type