Client

Struct Client 

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

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
Hide additional 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}
Source

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}
Source

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}
Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,