postgres_large_object 0.2.0

Large object support for rust-postgres
docs.rs failed to build postgres_large_object-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: postgres_large_object-0.7.1

rust-postgres-large-object

Build Status

A crate providing access to the Postgres large object API.

Documentation is available here.

Example

extern crate postgres;
extern crate postgres_large_object;

use std::old_path::Path;
use std::old_io::fs::File;
use std::old_io::util;

use postgres::{Connection, SslMode};
use postgres_large_object::{LargeObjectExt, LargeObjectTransactionExt, Mode};

fn main() {
    let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();

    let mut file = File::open(&Path::new("vacation_photos.tar.gz")).unwrap();
    let trans = conn.transaction().unwrap();
    let oid = trans.create_large_object().unwrap();
    {
        let mut large_object = trans.open_large_object(oid, Mode::Write).unwrap();
        util::copy(&mut file, &mut large_object).unwrap();
    }
    trans.commit().unwrap();

    let mut file = File::create(&Path::new("vacation_photos_copy.tar.gz")).unwrap();
    let trans = conn.transaction().unwrap();
    let mut large_object = trans.open_large_object(oid, Mode::Read).unwrap();
    util::copy(&mut large_object, &mut file).unwrap();
}