Trait cratedb::blob::BlobContainer [−][src]
pub trait BlobContainer { fn list<TBL: Into<String>>(
&self,
table: TBL
) -> Result<Vec<BlobRef>, BlobError>; fn put<TBL: Into<String>, B: Read + Seek>(
&self,
table: TBL,
blob: &mut B
) -> Result<BlobRef, BlobError>; fn delete(&self, blob: BlobRef) -> Result<(), BlobError>; fn get(&self, blob: &BlobRef) -> Result<Box<Read>, BlobError>; }
Trait for interfacing with CrateDB's BLOB features.
Required Methods
fn list<TBL: Into<String>>(&self, table: TBL) -> Result<Vec<BlobRef>, BlobError>
Fetches a list of [BlobRefs] from the provided table.
Errors
Errors occur when a cluster is unreachable, the table doesn't exist or other conditions appear: Crate.io docs
Examples
ⓘThis example is not tested
use blob::BlobContainer; let _ = c.query("create blob table my_blob_table", None::<Box<NoParams>>).unwrap(); for blob_ref in c.list("my_blob_table").unwrap() { println!("{:?}", blob_ref); }
fn put<TBL: Into<String>, B: Read + Seek>(
&self,
table: TBL,
blob: &mut B
) -> Result<BlobRef, BlobError>
&self,
table: TBL,
blob: &mut B
) -> Result<BlobRef, BlobError>
Uploads an existing blob to the cluster.
Errors
Errors occur when a cluster is unreachable, the blob already exists, or other conditions appear: Crate.io docs
Examples
ⓘThis example is not tested
use sql::QueryRunner; use blob::BlobContainer; let _ = c.query("create blob table my_blob_table", None::<Box<NoParams>>).unwrap(); let myblob: Vec<u8> = iter::repeat(0xA).take(1024).collect(); let r = c.put("my_blob_table", &mut Cursor::new(&myblob)).unwrap(); println!("Uploaded BLOB: {:?}", r);
fn delete(&self, blob: BlobRef) -> Result<(), BlobError>
Deletes a blob on the cluster using a BlobRef obtained from uploading.
Errors
Errors occur when a cluster is unreachable, the blob already exists, or other conditions appear: Crate.io docs
Examples
ⓘThis example is not tested
use blob::BlobContainer; let _ = c.delete(my_blob_ref);
fn get(&self, blob: &BlobRef) -> Result<Box<Read>, BlobError>
Fetches an existing blob from the cluster.
Errors
Errors occur when a cluster is unreachable, the blob already exists, or other conditions appear: Crate.io docs
Examples
ⓘThis example is not tested
use blob::BlobContainer; let _ = c.get(&my_blob_ref);