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: 'a + ToSql> ToSql for Slice<'a, T>

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

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

fn accepts(ty: &Type) -> bool

Derived Implementations

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

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