pub struct SanityClient {
pub config: SanityConfig,
pub client: Client,
pub payload: RequestPayload,
}Expand description
A client for interacting with the Sanity.io API.
This struct provides methods for making requests to the Sanity API. It uses the reqwest crate for HTTP requests.
Fields§
§config: SanityConfigConfiguration settings for the client.
client: ClientThe underlying HTTP client used for making requests.
payload: RequestPayloadThe payload to be sent with requests. This is likely a struct containing data relevant to the request type.
Implementations§
Source§impl SanityClient
impl SanityClient
Sourcepub fn new(config: SanityConfig) -> Result<Self, RequestError>
pub fn new(config: SanityConfig) -> Result<Self, RequestError>
Sourcepub fn body(&mut self, body: &str) -> &mut Self
pub fn body(&mut self, body: &str) -> &mut Self
Sets the request body.
This method allows you to set the request body for subsequent use.
Sourcepub async fn query(&mut self, body: &str) -> Result<&mut Self, RequestError>
pub async fn query(&mut self, body: &str) -> Result<&mut Self, RequestError>
Send a query to the Sanity API
Trait Implementations§
Source§impl Display for SanityClient
impl Display for SanityClient
Source§impl ORM for SanityClient
impl ORM for SanityClient
Source§fn get_by_id(&mut self, id: &str) -> &mut SanityClient
fn get_by_id(&mut self, id: &str) -> &mut SanityClient
Retrieves a single record from based on its ID. Read more
Source§fn get_by_ids(&mut self, ids: &[&str]) -> &mut SanityClient
fn get_by_ids(&mut self, ids: &[&str]) -> &mut SanityClient
Retrieves multiple records based on their IDs. Read more
Source§fn json<T: DeserializeOwned>(&mut self) -> Result<T, RequestError>
fn json<T: DeserializeOwned>(&mut self) -> Result<T, RequestError>
Serialized reterived data into JSON. Read more
Auto Trait Implementations§
impl Freeze for SanityClient
impl !RefUnwindSafe for SanityClient
impl Send for SanityClient
impl Sync for SanityClient
impl Unpin for SanityClient
impl !UnwindSafe for SanityClient
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> 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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.