pub struct SanityConfig {
pub query: Query,
/* private fields */
}
Fields§
§query: Query
Implementations§
Source§impl SanityConfig
impl SanityConfig
pub fn build_url(&mut self, query: Option<&str>) -> String
Sourcepub fn get(&mut self, query: &str) -> Result<Response, Error>
pub fn get(&mut self, query: &str) -> Result<Response, Error>
§Convenience wrapper for get request
Takes in arg query: &str
, which expects GROQ query language (Something like this: *[_type == 'recipe']
)
§Please note: There is NO syntax checking for GROQ query language at this time, but a macro is in the works
See the sanity docs for more
§Example usage:
extern crate sanity;
use sanity::helpers::get_json;
fn main() {
let mut sn = sanity::create(
"proj_id", // Sanity project ID to use
"data_set", // Data set to query. i.e. "development"
"Long_string_for_token", // Bearer token
false, // Use prod cdn or not
);
let res = sn.get(&String::from("*[_type == 'recipe']"));
if res.is_ok() {
println!("{:?}", get_json(res.unwrap()));
}
}
Trait Implementations§
Source§impl Clone for SanityConfig
impl Clone for SanityConfig
Source§fn clone(&self) -> SanityConfig
fn clone(&self) -> SanityConfig
Returns a copy of the value. Read more
1.0.0 · 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 Freeze for SanityConfig
impl RefUnwindSafe for SanityConfig
impl Send for SanityConfig
impl Sync for SanityConfig
impl Unpin for SanityConfig
impl UnwindSafe for SanityConfig
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