pub struct RequestKey(pub u64);Expand description
A hashed request key (FNV-1a of serialized request content).
Two RequestKey values are equal iff the underlying hash values are equal.
Collisions are theoretically possible but extremely rare for the prompt sizes
typical in LLM serving.
Tuple Fields§
§0: u64Implementations§
Source§impl RequestKey
impl RequestKey
Sourcepub fn from_str(s: &str) -> Self
pub fn from_str(s: &str) -> Self
Compute the key from a serialized request string.
§Example
use oxibonsai_runtime::dedup::RequestKey;
let k1 = RequestKey::from_str("hello world");
let k2 = RequestKey::from_str("hello world");
assert_eq!(k1, k2);Sourcepub fn from_messages(messages: &[(&str, &str)]) -> Self
pub fn from_messages(messages: &[(&str, &str)]) -> Self
Compute from a message list: FNV-1a over the concatenation of
role + "\x00" + content + "\x01" for every message pair, in order.
The sentinel bytes (\x00 and \x01) prevent role/content boundary
collisions (e.g. ("ab", "c") vs ("a", "bc")).
§Example
use oxibonsai_runtime::dedup::RequestKey;
let msgs = [("user", "What is Rust?")];
let k = RequestKey::from_messages(&msgs);
assert_eq!(k, RequestKey::from_messages(&msgs));Trait Implementations§
Source§impl Clone for RequestKey
impl Clone for RequestKey
Source§fn clone(&self) -> RequestKey
fn clone(&self) -> RequestKey
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 RequestKey
impl Debug for RequestKey
Source§impl Hash for RequestKey
impl Hash for RequestKey
Source§impl PartialEq for RequestKey
impl PartialEq for RequestKey
Source§fn eq(&self, other: &RequestKey) -> bool
fn eq(&self, other: &RequestKey) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for RequestKey
impl StructuralPartialEq for RequestKey
Auto Trait Implementations§
impl Freeze for RequestKey
impl RefUnwindSafe for RequestKey
impl Send for RequestKey
impl Sync for RequestKey
impl Unpin for RequestKey
impl UnsafeUnpin for RequestKey
impl UnwindSafe for RequestKey
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,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more