pub struct Rest { /* private fields */ }Implementations§
Source§impl Rest
impl Rest
pub fn new(forge: Forge, host: &str) -> Self
pub fn host(&self) -> &str
Sourcepub fn web_root(&self) -> String
pub fn web_root(&self) -> String
The web server’s root: the API root without its /api/v4 or
/api/v1, else https://HOST.
Sourcepub fn get(
&mut self,
path: &str,
etag: Option<&str>,
) -> Result<Response, Failure>
pub fn get( &mut self, path: &str, etag: Option<&str>, ) -> Result<Response, Failure>
GETs a path under the API root, or a full URL (a next page),
sending If-None-Match when etag is given. Statuses other than 401
are the caller’s to read.
Sourcepub fn json(&mut self, path: &str) -> Result<Option<Value>, Failure>
pub fn json(&mut self, path: &str) -> Result<Option<Value>, Failure>
GETs JSON; a 404 is None, and any other status but 200 an error.
Sourcepub fn list(&mut self, path: &str) -> Result<Option<Vec<Value>>, Failure>
pub fn list(&mut self, path: &str) -> Result<Option<Vec<Value>>, Failure>
Every page of a JSON list, up to MAX_PAGES; a 404 is None.
Sourcepub fn write(
&mut self,
method: Method,
path: &str,
body: &Value,
) -> Result<Response, Failure>
pub fn write( &mut self, method: Method, path: &str, body: &Value, ) -> Result<Response, Failure>
Sends a JSON body with a method that writes. It is not retried after a 5xx or a dropped connection, which can follow a write that succeeded.
Auto Trait Implementations§
impl !RefUnwindSafe for Rest
impl !UnwindSafe for Rest
impl Forget for Rest
impl Freeze for Rest
impl Move for Rest
impl Send for Rest
impl Sync for Rest
impl Unpin for Rest
impl UnsafeUnpin for Rest
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