pub struct PromptRef {
pub name: PromptName,
pub version: PromptVersion,
pub hash: Digest,
}Expand description
Which prompt text produced a turn.
Small and cheap to clone: three owned strings, no borrowed lifetimes and no content. It is safe to log and to store, because a name, a version and a digest are identifiers and never the prompt body.
§The obligation
A reference is only worth what its hash is worth. Whatever produces one owes
the reader this: hash is the digest of the text that was
actually used, computed with Digest::of_bytes over the UTF-8 bytes.
Build one with PromptRef::of_text and the obligation is met by
construction; build one field by field and PromptRef::matches is how a
test proves it.
Fields§
§name: PromptNameThe name the application asked for.
version: PromptVersionThe version its source returned.
hash: DigestBLAKE3 digest of the UTF-8 bytes of the prompt text.
Implementations§
Source§impl PromptRef
impl PromptRef
Sourcepub fn of_text(
name: impl Into<PromptName>,
version: impl Into<PromptVersion>,
text: &str,
) -> Self
pub fn of_text( name: impl Into<PromptName>, version: impl Into<PromptVersion>, text: &str, ) -> Self
A reference to text, with its hash computed here so it cannot be wrong.
Sourcepub fn new(
name: impl Into<PromptName>,
version: impl Into<PromptVersion>,
hash: Digest,
) -> Self
pub fn new( name: impl Into<PromptName>, version: impl Into<PromptVersion>, hash: Digest, ) -> Self
A reference assembled from parts, for a source that already holds a digest it trusts.
Prefer PromptRef::of_text; this constructor exists for the
deserialization-shaped cases, and it is the caller who then owes the
obligation described on the type.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PromptRef
impl<'de> Deserialize<'de> for PromptRef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PromptRef
Source§impl JsonSchema for PromptRef
impl JsonSchema for PromptRef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for PromptRef
impl Ord for PromptRef
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for PromptRef
impl PartialOrd for PromptRef
impl StructuralPartialEq for PromptRef
Auto Trait Implementations§
impl Freeze for PromptRef
impl RefUnwindSafe for PromptRef
impl Send for PromptRef
impl Sync for PromptRef
impl Unpin for PromptRef
impl UnsafeUnpin for PromptRef
impl UnwindSafe for PromptRef
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
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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
key and return true if they are equal.