pub struct IdempotencyKeyRule { /* private fields */ }Expand description
Length bounds for Idempotency-Key values on one route.
A key is min_bytes..=max_bytes bytes of visible ASCII (0x21..=0x7E). The key is opaque:
quotes are part of the key, and nothing is trimmed beyond what the HTTP stack removes.
Implementations§
Source§impl IdempotencyKeyRule
impl IdempotencyKeyRule
Sourcepub const fn new(min_bytes: usize, max_bytes: usize) -> Self
pub const fn new(min_bytes: usize, max_bytes: usize) -> Self
Creates a rule for keys of min_bytes..=max_bytes bytes.
§Panics
Panics unless 1 <= min_bytes <= max_bytes <= MAX_IDEMPOTENCY_KEY_BYTES. In a const
item the panic is a compile error. Use IdempotencyKeyRule::try_new for bounds read at
runtime.
Sourcepub const fn try_new(
min_bytes: usize,
max_bytes: usize,
) -> Result<Self, InvalidIdempotencyKeyRule>
pub const fn try_new( min_bytes: usize, max_bytes: usize, ) -> Result<Self, InvalidIdempotencyKeyRule>
Creates a rule from bounds read at runtime.
Sourcepub fn parse<'h>(
&self,
value: &'h HeaderValue,
) -> Result<IdempotencyKey<'h>, InvalidIdempotencyKey>
pub fn parse<'h>( &self, value: &'h HeaderValue, ) -> Result<IdempotencyKey<'h>, InvalidIdempotencyKey>
Parses one Idempotency-Key field value.
Sourcepub fn required<'h>(
&self,
headers: &'h HeaderMap,
) -> Result<IdempotencyKey<'h>, IdempotencyError>
pub fn required<'h>( &self, headers: &'h HeaderMap, ) -> Result<IdempotencyKey<'h>, IdempotencyError>
Reads the key from a route that requires Idempotency-Key.
A missing header returns IdempotencyError::Required.
Sourcepub fn optional<'h>(
&self,
headers: &'h HeaderMap,
) -> Result<Option<IdempotencyKey<'h>>, IdempotencyError>
pub fn optional<'h>( &self, headers: &'h HeaderMap, ) -> Result<Option<IdempotencyKey<'h>>, IdempotencyError>
Reads the key from a route where Idempotency-Key is optional.
A missing header returns Ok(None), which runs the mutation without a replay record.
Trait Implementations§
Source§impl Clone for IdempotencyKeyRule
impl Clone for IdempotencyKeyRule
impl Copy for IdempotencyKeyRule
Source§impl Debug for IdempotencyKeyRule
impl Debug for IdempotencyKeyRule
impl Eq for IdempotencyKeyRule
Source§impl PartialEq for IdempotencyKeyRule
impl PartialEq for IdempotencyKeyRule
impl StructuralPartialEq for IdempotencyKeyRule
Auto Trait Implementations§
impl Freeze for IdempotencyKeyRule
impl RefUnwindSafe for IdempotencyKeyRule
impl Send for IdempotencyKeyRule
impl Sync for IdempotencyKeyRule
impl Unpin for IdempotencyKeyRule
impl UnsafeUnpin for IdempotencyKeyRule
impl UnwindSafe for IdempotencyKeyRule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
key and return true if they are equal.