pub struct RestClient { /* private fields */ }Available on crate feature
http only.Expand description
Reqwest-based HTTP client with builder-style header / TLS configuration.
let mut c = vynil_core::http::RestClient::new("https://example.com");
c.add_header_bearer("token");
// let resp: serde_json::Value = c.json_get("api/v1/foo").unwrap();Implementations§
Source§impl RestClient
impl RestClient
pub fn new(base: &str) -> Self
pub fn baseurl(&mut self, base: &str) -> &mut RestClient
pub fn set_server_ca(&mut self, ca: &str)
pub fn set_mtls(&mut self, cert: &str, key: &str)
pub fn baseurl_rhai(&mut self, base: String)
pub fn headers_reset(&mut self) -> &mut RestClient
pub fn headers_reset_rhai(&mut self)
pub fn add_header(&mut self, key: &str, value: &str) -> &mut RestClient
pub fn add_header_rhai(&mut self, key: String, value: String)
pub fn add_header_json_content(&mut self) -> &mut RestClient
pub fn add_header_json_accept(&mut self) -> &mut RestClient
pub fn add_header_json(&mut self)
pub fn add_header_bearer(&mut self, token: &str)
pub fn add_header_basic(&mut self, username: &str, password: &str)
pub fn http_get(&mut self, path: &str) -> Result<Response, Error>
pub fn body_get(&mut self, path: &str) -> Result<String>
pub fn json_get(&mut self, path: &str) -> Result<Value>
pub fn rhai_get(&mut self, path: String) -> RhaiRes<Map>
pub fn http_head(&mut self, path: &str) -> Result<Response, Error>
pub fn header_head(&mut self, path: &str) -> Result<Vec<(String, String)>>
pub fn rhai_head(&mut self, path: String) -> RhaiRes<Map>
pub fn http_patch(&mut self, path: &str, body: &str) -> Result<Response>
pub fn body_patch(&mut self, path: &str, body: &str) -> Result<String>
pub fn json_patch(&mut self, path: &str, input: &Value) -> Result<Value>
pub fn rhai_patch(&mut self, path: String, val: Dynamic) -> RhaiRes<Map>
pub fn http_put(&mut self, path: &str, body: &str) -> Result<Response>
pub fn body_put(&mut self, path: &str, body: &str) -> Result<String>
pub fn json_put(&mut self, path: &str, input: &Value) -> Result<Value>
pub fn rhai_put(&mut self, path: String, val: Dynamic) -> RhaiRes<Map>
pub fn http_post(&mut self, path: &str, body: &str) -> Result<Response>
pub fn body_post(&mut self, path: &str, body: &str) -> Result<String>
pub fn json_post(&mut self, path: &str, input: &Value) -> Result<Value>
pub fn rhai_post(&mut self, path: String, val: Dynamic) -> RhaiRes<Map>
pub fn http_post_form( &mut self, path: &str, params: &[(String, String)], ) -> Result<Response>
pub fn rhai_post_form(&mut self, path: String, val: Map) -> RhaiRes<Map>
pub fn http_delete(&mut self, path: &str) -> Result<Response>
pub fn body_delete(&mut self, path: &str) -> Result<String>
pub fn json_delete(&mut self, path: &str) -> Result<Value>
pub fn rhai_delete(&mut self, path: String) -> RhaiRes<Map>
pub fn obj_read( &mut self, method: ReadMethod, path: &str, key: &str, ) -> Result<Value>
pub fn obj_create( &mut self, method: CreateMethod, path: &str, input: &Value, ) -> Result<Value>
pub fn obj_update( &mut self, method: UpdateMethod, path: &str, key: &str, input: &Value, use_slash: bool, ) -> Result<Value>
pub fn obj_delete( &mut self, method: DeleteMethod, path: &str, key: &str, ) -> Result<Value>
pub fn http_delete_with_body( &mut self, path: &str, body: &str, ) -> Result<Response>
pub fn body_delete_with_body( &mut self, path: &str, body: &str, ) -> Result<String>
pub fn json_delete_with_body( &mut self, path: &str, input: &Value, ) -> Result<Value>
pub fn rhai_delete_with_body( &mut self, path: String, val: Dynamic, ) -> RhaiRes<Map>
pub fn obj_delete_with_body( &mut self, method: DeleteMethod, path: &str, input: &Value, ) -> Result<Value>
Trait Implementations§
Source§impl Clone for RestClient
impl Clone for RestClient
Source§fn clone(&self) -> RestClient
fn clone(&self) -> RestClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RestClient
impl !UnwindSafe for RestClient
impl Freeze for RestClient
impl Send for RestClient
impl Sync for RestClient
impl Unpin for RestClient
impl UnsafeUnpin for RestClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Available on crate feature
map-response-body only.Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using gRPC headers. Read more
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Available on crate feature
follow-redirect only.Source§impl<T> Variant for T
impl<T> Variant for T
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert this
Variant trait object to &mut dyn Any.Source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Convert this
Variant trait object to Box<dyn Any>.