pub struct IdempotencyKey(/* private fields */);Available on crate feature
unstable_protocol_v2 only.Expand description
A key the Client generates to identify one session/prompt submission across attempts.
The key is an opaque, case-sensitive string of 1 to 255 characters. It is scoped to the
session named by the request’s sessionId.
See protocol docs: Retrying a prompt
Implementations§
Source§impl IdempotencyKey
impl IdempotencyKey
Sourcepub const MAX_LENGTH: usize = 255
pub const MAX_LENGTH: usize = 255
The maximum length of a key, in characters.
Sourcepub fn new(
key: impl Into<Arc<str>>,
) -> Result<IdempotencyKey, InvalidIdempotencyKey>
pub fn new( key: impl Into<Arc<str>>, ) -> Result<IdempotencyKey, InvalidIdempotencyKey>
Wraps a string as a typed IdempotencyKey.
§Errors
Returns InvalidIdempotencyKey if the key is empty or longer than
Self::MAX_LENGTH characters.
Sourcepub fn generate() -> IdempotencyKey
Available on crate feature uuid only.
pub fn generate() -> IdempotencyKey
uuid only.Generates a key from a random version 4 UUID (RFC 9562).
Generate one key per submission, when the user submits the input, and store it with the pending input. Every attempt for that submission sends the same key.
Trait Implementations§
Source§impl AsRef<str> for IdempotencyKey
impl AsRef<str> for IdempotencyKey
Source§impl Clone for IdempotencyKey
impl Clone for IdempotencyKey
Source§fn clone(&self) -> IdempotencyKey
fn clone(&self) -> IdempotencyKey
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 moreSource§impl Debug for IdempotencyKey
impl Debug for IdempotencyKey
Source§impl<'de> Deserialize<'de> for IdempotencyKey
impl<'de> Deserialize<'de> for IdempotencyKey
Source§fn deserialize<D>(
deserializer: D,
) -> Result<IdempotencyKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<IdempotencyKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for IdempotencyKey
impl Display for IdempotencyKey
impl Eq for IdempotencyKey
Source§impl From<Uuid> for IdempotencyKey
Available on crate feature uuid only.
impl From<Uuid> for IdempotencyKey
Available on crate feature
uuid only.Source§fn from(uuid: Uuid) -> IdempotencyKey
fn from(uuid: Uuid) -> IdempotencyKey
Uses the UUID’s hyphenated lowercase form. It is 36 characters, so it is always a valid key.
Source§impl FromStr for IdempotencyKey
impl FromStr for IdempotencyKey
Source§type Err = InvalidIdempotencyKey
type Err = InvalidIdempotencyKey
The associated error which can be returned from parsing.
Source§fn from_str(
key: &str,
) -> Result<IdempotencyKey, <IdempotencyKey as FromStr>::Err>
fn from_str( key: &str, ) -> Result<IdempotencyKey, <IdempotencyKey as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for IdempotencyKey
impl Hash for IdempotencyKey
Source§impl JsonSchema for IdempotencyKey
impl JsonSchema for IdempotencyKey
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for IdempotencyKey
impl PartialEq for IdempotencyKey
Source§impl Serialize for IdempotencyKey
impl Serialize for IdempotencyKey
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for IdempotencyKey
Source§impl TryFrom<&str> for IdempotencyKey
impl TryFrom<&str> for IdempotencyKey
Source§type Error = InvalidIdempotencyKey
type Error = InvalidIdempotencyKey
The type returned in the event of a conversion error.
Source§fn try_from(
key: &str,
) -> Result<IdempotencyKey, <IdempotencyKey as TryFrom<&str>>::Error>
fn try_from( key: &str, ) -> Result<IdempotencyKey, <IdempotencyKey as TryFrom<&str>>::Error>
Performs the conversion.
Source§impl TryFrom<String> for IdempotencyKey
impl TryFrom<String> for IdempotencyKey
Source§type Error = InvalidIdempotencyKey
type Error = InvalidIdempotencyKey
The type returned in the event of a conversion error.
Source§fn try_from(
key: String,
) -> Result<IdempotencyKey, <IdempotencyKey as TryFrom<String>>::Error>
fn try_from( key: String, ) -> Result<IdempotencyKey, <IdempotencyKey as TryFrom<String>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl Forget for IdempotencyKey
impl Freeze for IdempotencyKey
impl Move for IdempotencyKey
impl RefUnwindSafe for IdempotencyKey
impl Send for IdempotencyKey
impl Sync for IdempotencyKey
impl Unpin for IdempotencyKey
impl UnsafeUnpin for IdempotencyKey
impl UnwindSafe for IdempotencyKey
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Compare self to
key and return true if they are equal.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> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.