Struct Client

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

The main entry point to the RING webservice.

Implementations§

Source§

impl Client

Source

pub fn new() -> Self

Creates a RING web client.

Examples found in repository?
examples/simple.rs (line 18)
14fn main() -> Result<(), Box<dyn Debug + 'static>> {
15    // Parse command-line arguments
16    let mut args: Vec<_> = env::args().collect();
17    let err_msg = "usage: simple [id | file] PDB_ID_OR_FILE_NAME";
18    let client = Client::new();
19
20    if args.len() != 3 {
21        return Err(Box::new(err_msg));
22    }
23
24    // Submit either a PDB ID or a PDB file
25    let submit_resp = match args[1].as_str() {
26        "id" => {
27            let req = SubmitId {
28                pdb_id: args.remove(2),
29                settings: Settings::default(),
30            };
31            client.send(req).map_err(|e| Box::new(e) as _)?
32        }
33        "file" => {
34            let req = SubmitStructure::with_pdb_file(&args[2])
35                .map_err(|e| Box::new(e) as _)?;
36            client.send(req).map_err(|e| Box::new(e) as _)?
37        }
38        _ => return Err(Box::new(err_msg)),
39    };
40
41    println!("Submitted; response = {:#?}", submit_resp);
42
43    // Wait for the result to be ready; poll status endpoint
44    loop {
45        let req = Status {
46            job_id: submit_resp.job_id.clone()
47        };
48        let status_resp = client.send(req).map_err(|e| Box::new(e) as _)?;
49
50        println!("Job ID: {}, status: {}", status_resp.job_id, status_resp.status);
51
52        match status_resp.status {
53            JobStatus::Failed => return Err(Box::new(
54                format!("Job failed: {:#?}", status_resp)
55            )),
56            JobStatus::Complete => break,
57            _ => thread::sleep(Duration::from_secs(5)),
58        }
59    }
60
61    // Retrieve results
62    let req = RetrieveResult {
63        job_id: submit_resp.job_id.clone()
64    };
65    let result_resp = client.send(req).map_err(|e| Box::new(e) as _)?;
66
67    println!("{:#?}", result_resp);
68
69    Ok(())
70}
Source

pub fn send<R: Request>(&self, request: R) -> Result<R::Response>

Sending requests.

Examples found in repository?
examples/simple.rs (line 31)
14fn main() -> Result<(), Box<dyn Debug + 'static>> {
15    // Parse command-line arguments
16    let mut args: Vec<_> = env::args().collect();
17    let err_msg = "usage: simple [id | file] PDB_ID_OR_FILE_NAME";
18    let client = Client::new();
19
20    if args.len() != 3 {
21        return Err(Box::new(err_msg));
22    }
23
24    // Submit either a PDB ID or a PDB file
25    let submit_resp = match args[1].as_str() {
26        "id" => {
27            let req = SubmitId {
28                pdb_id: args.remove(2),
29                settings: Settings::default(),
30            };
31            client.send(req).map_err(|e| Box::new(e) as _)?
32        }
33        "file" => {
34            let req = SubmitStructure::with_pdb_file(&args[2])
35                .map_err(|e| Box::new(e) as _)?;
36            client.send(req).map_err(|e| Box::new(e) as _)?
37        }
38        _ => return Err(Box::new(err_msg)),
39    };
40
41    println!("Submitted; response = {:#?}", submit_resp);
42
43    // Wait for the result to be ready; poll status endpoint
44    loop {
45        let req = Status {
46            job_id: submit_resp.job_id.clone()
47        };
48        let status_resp = client.send(req).map_err(|e| Box::new(e) as _)?;
49
50        println!("Job ID: {}, status: {}", status_resp.job_id, status_resp.status);
51
52        match status_resp.status {
53            JobStatus::Failed => return Err(Box::new(
54                format!("Job failed: {:#?}", status_resp)
55            )),
56            JobStatus::Complete => break,
57            _ => thread::sleep(Duration::from_secs(5)),
58        }
59    }
60
61    // Retrieve results
62    let req = RetrieveResult {
63        job_id: submit_resp.job_id.clone()
64    };
65    let result_resp = client.send(req).map_err(|e| Box::new(e) as _)?;
66
67    println!("{:#?}", result_resp);
68
69    Ok(())
70}

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

Source§

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

Source§

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