pub struct LoadedPrompt { /* private fields */ }Expand description
A prompt, and the reference that names it.
The two fields are private and the only constructors compute or verify the
hash, so a value of this type carries the PromptSource promise by
construction: reference().hash is the digest of text().
Implementations§
Source§impl LoadedPrompt
impl LoadedPrompt
Sourcepub fn new(
name: impl Into<PromptName>,
version: impl Into<PromptVersion>,
text: impl Into<String>,
) -> Self
pub fn new( name: impl Into<PromptName>, version: impl Into<PromptVersion>, text: impl Into<String>, ) -> Self
Builds a prompt and derives its reference from the text.
This is the constructor a source should reach for: there is no way to get the hash wrong.
Sourcepub fn from_parts(
reference: PromptRef,
text: impl Into<String>,
) -> Result<Self, PromptError>
pub fn from_parts( reference: PromptRef, text: impl Into<String>, ) -> Result<Self, PromptError>
Builds a prompt from a reference somebody else produced, checking that the reference is telling the truth.
§Errors
PromptError::InconsistentReference when reference.hash is not the
digest of text.
Sourcepub fn name(&self) -> &PromptName
pub fn name(&self) -> &PromptName
The name it was loaded under.
Sourcepub fn version(&self) -> &PromptVersion
pub fn version(&self) -> &PromptVersion
The version it came back at.
Sourcepub fn into_parts(self) -> (PromptRef, String)
pub fn into_parts(self) -> (PromptRef, String)
Consumes the value and returns both halves.
Trait Implementations§
Source§impl Clone for LoadedPrompt
impl Clone for LoadedPrompt
Source§impl Debug for LoadedPrompt
impl Debug for LoadedPrompt
impl Eq for LoadedPrompt
Source§impl PartialEq for LoadedPrompt
impl PartialEq for LoadedPrompt
impl StructuralPartialEq for LoadedPrompt
Auto Trait Implementations§
impl Freeze for LoadedPrompt
impl RefUnwindSafe for LoadedPrompt
impl Send for LoadedPrompt
impl Sync for LoadedPrompt
impl Unpin for LoadedPrompt
impl UnsafeUnpin for LoadedPrompt
impl UnwindSafe for LoadedPrompt
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,
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.