pub struct PrefixChain { /* private fields */ }Expand description
The hash chain of one request’s prompt prefix.
Implementations§
Source§impl PrefixChain
impl PrefixChain
Sourcepub fn of(definitions: &[ToolDefinition], messages: &[Message]) -> Self
pub fn of(definitions: &[ToolDefinition], messages: &[Message]) -> Self
The chain of a request carrying definitions and messages.
§Panics
Panics when a message or tool definition cannot be serialized, which would mean the request itself cannot be sent.
Sourcepub fn first_divergence(&self, previous: &Self) -> Option<PrefixBlock>
pub fn first_divergence(&self, previous: &Self) -> Option<PrefixBlock>
The first block of previous’s cached prefix that this request does
not repeat byte for byte, or None when it repeats all of it.
A block this request no longer has at all counts as changed.
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
The number of blocks in the chain, the tool definitions included.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Whether the chain has no blocks; never true for a chain built by
PrefixChain::of, which always has the tool definitions block.
Sourcepub const fn cached_blocks(&self) -> usize
pub const fn cached_blocks(&self) -> usize
How many leading blocks the request asks the provider to cache.
Trait Implementations§
Source§impl Clone for PrefixChain
impl Clone for PrefixChain
Source§impl Debug for PrefixChain
impl Debug for PrefixChain
Source§impl<'de> Deserialize<'de> for PrefixChain
impl<'de> Deserialize<'de> for PrefixChain
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PrefixChain
Source§impl PartialEq for PrefixChain
impl PartialEq for PrefixChain
Source§impl Serialize for PrefixChain
impl Serialize for PrefixChain
impl StructuralPartialEq for PrefixChain
Auto Trait Implementations§
impl Forget for PrefixChain
impl Freeze for PrefixChain
impl Move for PrefixChain
impl RefUnwindSafe for PrefixChain
impl Send for PrefixChain
impl Sync for PrefixChain
impl Unpin for PrefixChain
impl UnsafeUnpin for PrefixChain
impl UnwindSafe for PrefixChain
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.