Struct postgres::types::Slice [] [src]

pub struct Slice<'a, T: 'a + ToSql>(pub &'a [T]);

An adapter type mapping slices to Postgres arrays.

Slice's ToSql implementation maps the slice to a one-dimensional Postgres array of the relevant type. This is particularly useful with the ANY function to match a column against multiple values without having to dynamically construct the query string.

Examples

let values = &[1i32, 2, 3, 4, 5, 6];
let stmt = try!(conn.prepare("SELECT * FROM foo WHERE id = ANY($1)"));
for row in &try!(stmt.query(&[&Slice(values)])) {
    // ...
}

Trait Implementations

impl<'a, T: Debug + 'a + ToSql> Debug for Slice<'a, T>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<'a, T: 'a + ToSql> ToSql for Slice<'a, T>
[src]

fn to_sql_checked(&self, ty: &Type, out: &mut Write) -> Result<IsNull>

An adaptor method used internally by Rust-Postgres. Read more

fn to_sql<W: Write + ?Sized>(&self, ty: &Type, w: &mut W) -> Result<IsNull>

Converts the value of self into the binary format of the specified Postgres Type, writing it to out. Read more

fn accepts(ty: &Type) -> bool

Determines if a value of this type can be converted to the specified Postgres Type. Read more