Struct async_graphql::CacheControl
source · pub struct CacheControl {
pub public: bool,
pub max_age: i32,
}
Expand description
Cache control value
§Examples
use async_graphql::*;
struct Query;
#[Object(cache_control(max_age = 60))]
impl Query {
#[graphql(cache_control(max_age = 30))]
async fn value1(&self) -> i32 {
0
}
#[graphql(cache_control(private))]
async fn value2(&self) -> i32 {
0
}
#[graphql(cache_control(no_cache))]
async fn value3(&self) -> i32 {
0
}
}
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema
.execute("{ value1 }")
.await
.into_result()
.unwrap()
.cache_control,
CacheControl {
public: true,
max_age: 30
}
);
assert_eq!(
schema
.execute("{ value2 }")
.await
.into_result()
.unwrap()
.cache_control,
CacheControl {
public: false,
max_age: 60
}
);
assert_eq!(
schema
.execute("{ value1 value2 }")
.await
.into_result()
.unwrap()
.cache_control,
CacheControl {
public: false,
max_age: 30
}
);
assert_eq!(
schema
.execute("{ value1 value2 value3 }")
.await
.into_result()
.unwrap()
.cache_control,
CacheControl {
public: false,
max_age: -1
}
);
Fields§
§public: bool
Scope is public, default is true.
max_age: i32
Cache max age, -1
represent no-cache
, default is 0.
Implementations§
Trait Implementations§
source§impl Clone for CacheControl
impl Clone for CacheControl
source§fn clone(&self) -> CacheControl
fn clone(&self) -> CacheControl
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 moresource§impl Debug for CacheControl
impl Debug for CacheControl
source§impl Default for CacheControl
impl Default for CacheControl
source§impl PartialEq for CacheControl
impl PartialEq for CacheControl
source§fn eq(&self, other: &CacheControl) -> bool
fn eq(&self, other: &CacheControl) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for CacheControl
impl Eq for CacheControl
impl StructuralPartialEq for CacheControl
Auto Trait Implementations§
impl Freeze for CacheControl
impl RefUnwindSafe for CacheControl
impl Send for CacheControl
impl Sync for CacheControl
impl Unpin for CacheControl
impl UnwindSafe for CacheControl
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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.