pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/putblob.rs (line 20)
8async fn main(){
9 env_logger::init();
10 let argv = std::env::args().collect::<Vec<_>>();
11 let mut blob = vec![];
12 if argv.len() == 2 {
13 let fname = &argv[1];
14 let f = std::fs::File::open(fname).expect(fname);
15 BufReader::new(f).read_to_end(&mut blob).expect(fname);
16 }
17 else {
18 std::io::stdin().lock().read_to_end(&mut blob).expect("reading stdin");
19 }
20 let c = blob_api::Client::new();
21 let blobid = c.upload(&blob).await.expect("upload blob");
22 println!("{}", blobid.hex());
23}More examples
examples/getblob.rs (line 25)
7async fn main(){
8 env_logger::init();
9 let argv = std::env::args().collect::<Vec<_>>();
10 let hexid;
11 let mark_done;
12 if argv.len() == 2 {
13 hexid = &argv[1];
14 mark_done = false;
15 }
16 else if argv.len() == 3 && argv[1] == "-d" {
17 hexid = &argv[2];
18 mark_done = true;
19 }
20 else {
21 eprintln!("usage: {} HEXBLOBREF", std::env::args().next().unwrap());
22 std::process::exit(1);
23 }
24 let blobref = blob_api::BlobRef::from_hex(hexid).expect("invalid id given.");
25 let c = blob_api::Client::new();
26 let blob = c.download(&blobref).await.expect("retrieving blob");
27 std::io::stdout().lock().write_all(&blob).expect("write out failed");
28 if mark_done {
29 c.mark_done(&blobref.id).await.expect("mark_done failed");
30 }
31}Sourcepub async fn download(&self, blobref: &BlobRef) -> Result<Vec<u8>, Error>
pub async fn download(&self, blobref: &BlobRef) -> Result<Vec<u8>, Error>
Examples found in repository?
examples/getblob.rs (line 26)
7async fn main(){
8 env_logger::init();
9 let argv = std::env::args().collect::<Vec<_>>();
10 let hexid;
11 let mark_done;
12 if argv.len() == 2 {
13 hexid = &argv[1];
14 mark_done = false;
15 }
16 else if argv.len() == 3 && argv[1] == "-d" {
17 hexid = &argv[2];
18 mark_done = true;
19 }
20 else {
21 eprintln!("usage: {} HEXBLOBREF", std::env::args().next().unwrap());
22 std::process::exit(1);
23 }
24 let blobref = blob_api::BlobRef::from_hex(hexid).expect("invalid id given.");
25 let c = blob_api::Client::new();
26 let blob = c.download(&blobref).await.expect("retrieving blob");
27 std::io::stdout().lock().write_all(&blob).expect("write out failed");
28 if mark_done {
29 c.mark_done(&blobref.id).await.expect("mark_done failed");
30 }
31}Sourcepub async fn mark_done(&self, blobid: &BlobId) -> Result<(), Error>
pub async fn mark_done(&self, blobid: &BlobId) -> Result<(), Error>
Examples found in repository?
examples/getblob.rs (line 29)
7async fn main(){
8 env_logger::init();
9 let argv = std::env::args().collect::<Vec<_>>();
10 let hexid;
11 let mark_done;
12 if argv.len() == 2 {
13 hexid = &argv[1];
14 mark_done = false;
15 }
16 else if argv.len() == 3 && argv[1] == "-d" {
17 hexid = &argv[2];
18 mark_done = true;
19 }
20 else {
21 eprintln!("usage: {} HEXBLOBREF", std::env::args().next().unwrap());
22 std::process::exit(1);
23 }
24 let blobref = blob_api::BlobRef::from_hex(hexid).expect("invalid id given.");
25 let c = blob_api::Client::new();
26 let blob = c.download(&blobref).await.expect("retrieving blob");
27 std::io::stdout().lock().write_all(&blob).expect("write out failed");
28 if mark_done {
29 c.mark_done(&blobref.id).await.expect("mark_done failed");
30 }
31}Sourcepub async fn upload(&self, plainblob: &[u8]) -> Result<BlobRef>
pub async fn upload(&self, plainblob: &[u8]) -> Result<BlobRef>
Examples found in repository?
examples/putblob.rs (line 21)
8async fn main(){
9 env_logger::init();
10 let argv = std::env::args().collect::<Vec<_>>();
11 let mut blob = vec![];
12 if argv.len() == 2 {
13 let fname = &argv[1];
14 let f = std::fs::File::open(fname).expect(fname);
15 BufReader::new(f).read_to_end(&mut blob).expect(fname);
16 }
17 else {
18 std::io::stdin().lock().read_to_end(&mut blob).expect("reading stdin");
19 }
20 let c = blob_api::Client::new();
21 let blobid = c.upload(&blob).await.expect("upload blob");
22 println!("{}", blobid.hex());
23}Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more