pub struct RequestMetadata(/* private fields */);Expand description
Non-personal labels attached to a call.
Values are validated at insertion: at most MAX_METADATA_VALUE_LEN bytes,
no control characters and no whitespace. That is enough for a turn id, a
workflow key or an experiment label, and not enough for a sentence a user
typed (spec §25.5).
Implementations§
Source§impl RequestMetadata
impl RequestMetadata
Sourcepub fn insert(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
) -> Result<(), MetadataError>
pub fn insert( &mut self, key: impl Into<String>, value: impl Into<String>, ) -> Result<(), MetadataError>
Inserts a label, replacing any previous value for key.
use turnframe_provider::request::RequestMetadata;
let mut metadata = RequestMetadata::new();
metadata.insert("workflow", "trip").unwrap();
// Free user text cannot be smuggled through metadata.
assert!(metadata.insert("note", "the traveler said hello").is_err());Trait Implementations§
Source§impl Clone for RequestMetadata
impl Clone for RequestMetadata
Source§impl Debug for RequestMetadata
impl Debug for RequestMetadata
Source§impl Default for RequestMetadata
impl Default for RequestMetadata
Source§impl<'de> Deserialize<'de> for RequestMetadata
impl<'de> Deserialize<'de> for RequestMetadata
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialization runs the same validation as RequestMetadata::insert,
so a request read back from a fixture cannot carry a label the builder
would have refused.
impl Eq for RequestMetadata
Source§impl PartialEq for RequestMetadata
impl PartialEq for RequestMetadata
Source§impl Serialize for RequestMetadata
impl Serialize for RequestMetadata
impl StructuralPartialEq for RequestMetadata
Auto Trait Implementations§
impl Freeze for RequestMetadata
impl RefUnwindSafe for RequestMetadata
impl Send for RequestMetadata
impl Sync for RequestMetadata
impl Unpin for RequestMetadata
impl UnsafeUnpin for RequestMetadata
impl UnwindSafe for RequestMetadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.