pub fn as_type(&self, scalar_type: ScalarType) -> Result<PrismaValue, DatamodelError> {
        match scalar_type {
            ScalarType::Int => self.as_int().map(PrismaValue::Int),
            ScalarType::Float => self.as_float().map(PrismaValue::Float),
            ScalarType::Boolean => self.as_bool().map(PrismaValue::Boolean),
            ScalarType::DateTime => self.as_date_time().map(PrismaValue::DateTime),
            ScalarType::String => self.as_str().map(PrismaValue::String),
            ScalarType::Json => self.as_str().map(PrismaValue::String),
            ScalarType::Bytes => self.as_str().and_then(|s| {
                prisma_value::decode_bytes(&s).map(PrismaValue::Bytes).map_err(|_| {
                    DatamodelError::new_validation_error(&format!("Invalid base64 string '{}'.", s), self.span())
                })
            }),

            ScalarType::Decimal => self.as_float().map(PrismaValue::Float),
            ScalarType::BigInt => self.as_int().map(PrismaValue::BigInt),
        }
    }
/// Attempts to parse the wrapped value
/// to a given prisma type.
Attempts to parse the wrapped value
to a given prisma type.
Attempts to parse the wrapped value to a given prisma type .
pub fn as_type(&self, scalar_type: ScalarType) -> Result<PrismaValue, DatamodelError> {
        match scalar_type {
            ScalarType::Int => self.as_int().map(PrismaValue::Int),
            ScalarType::Float => self.as_float().map(PrismaValue::Float),
            ScalarType::Boolean => self.as_bool().map(PrismaValue::Boolean),
            ScalarType::DateTime => self.as_date_time().map(PrismaValue::DateTime),
            ScalarType::String => self.as_str().map(PrismaValue::String),
            ScalarType::Json => self.as_str().map(PrismaValue::String),
            ScalarType::Bytes => self.as_str().and_then(|s| {
                prisma_value::decode_bytes(&s).map(PrismaValue::Bytes).map_err(|_| {
                    DatamodelError::new_validation_error(&format!("Invalid base64 string '{}'.", s), self.span())
                })
            }),
            ScalarType::Decimal => self.as_float().map(PrismaValue::Float),
            ScalarType::BigInt => self.as_int().map(PrismaValue::BigInt),
        }
    }
pub fn as_type ( & self , scalar_type : ScalarType ) -> Result < PrismaValue , DatamodelError > { match scalar_type { ScalarType :: Int => self . as_int ( ) . map ( PrismaValue :: Int ) , ScalarType :: Float => self . as_float ( ) . map ( PrismaValue :: Float ) , ScalarType :: Boolean => self . as_bool ( ) . map ( PrismaValue :: Boolean ) , ScalarType :: DateTime => self . as_date_time ( ) . map ( PrismaValue :: DateTime ) , ScalarType :: String => self . as_str ( ) . map ( PrismaValue :: String ) , ScalarType :: Json => self . as_str ( ) . map ( PrismaValue :: String ) , ScalarType :: Bytes => self . as_str ( ) . and_then ( | s | { prisma_value :: decode_bytes ( & s ) . map ( PrismaValue :: Bytes ) . map_err ( | _ | { DatamodelError :: new_validation_error ( & format ! ( " " s ) , self . span ( ) ) } ) } ) , ScalarType :: Decimal => self . as_float ( ) . map ( PrismaValue :: Float ) , ScalarType :: BigInt => self . as_int ( ) . map ( PrismaValue :: BigInt ) , } }
Attempts to parse the wrapped value
to a given prisma type.
Attempts to parse the wrapped value to a given prisma type .
&self
scalar_type
ScalarType
&self
scalar_type
ScalarType