Skip to main content

IntoValue

Trait IntoValue 

Source
pub trait IntoValue {
    // Required method
    fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>;
}
Expand description

Trait for types that can be inserted into a Hyper table.

This trait is implemented for common Rust types, allowing them to be used with Inserter::add_row() for type-safe insertion.

§Supported Types

  • Integers: i16, i32, i64
  • Floats: f32, f64
  • bool
  • &str, String
  • Option<T> where T: IntoValue (for nullable columns)
  • Date/time types: Date, Time, Timestamp, Interval
  • Numeric, Geography, Oid, Vec<u8> (bytes)

§Example

use hyperdb_api::{Connection, CreateMode, Catalog, TableDefinition, Inserter, IntoValue, SqlType, Result};

fn main() -> Result<()> {
    let conn = Connection::connect("localhost:7483", "test.hyper", CreateMode::CreateIfNotExists)?;

    let table_def = TableDefinition::new("example")
        .add_required_column("a", SqlType::int())
        .add_nullable_column("b", SqlType::text())
        .add_nullable_column("c", SqlType::double());
    Catalog::new(&conn).create_table(&table_def)?;

    let mut inserter = Inserter::new(&conn, &table_def)?;

    // IntoValue allows adding rows with mixed types
    inserter.add_row(&[&1i32, &"Alice", &Some(3.14f64)])?;
    inserter.add_row(&[&2i32, &"Bob", &None::<f64>])?; // NULL value

    inserter.execute()?;
    Ok(())
}

Required Methods§

Source

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Adds this value to the inserter.

§Errors

Implementations call the matching Inserter::add_* method and forward its error — see Inserter::add_bool for the shared failure modes (too many columns, NULL into non-nullable, etc).

Implementations on Foreign Types§

Source§

impl IntoValue for &&str

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &bool

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &f32

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &f64

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &i16

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &i32

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &i64

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &str

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &String

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for &[u8]

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for bool

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for f32

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for f64

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for i16

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for i32

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for i64

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for str

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for String

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for Vec<u8>

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl IntoValue for [u8]

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Source§

impl<T: IntoValue> IntoValue for Option<T>

Source§

fn add_to_inserter(&self, inserter: &mut Inserter<'_>) -> Result<()>

Implementors§