pub struct Client { /* private fields */ }
Expand description
The main entry point to the RING webservice.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Self
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}
Sourcepub fn send<R: Request>(&self, request: R) -> Result<R::Response>
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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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