pub struct H2SessionCache<K> { /* private fields */ }Expand description
HTTP/2 session cache with generic connection keys.
Uses DashMap<K, Mutex<H2ConnectionState>> to provide per-key
serialization. The DashMap shard lock is held only briefly (to look up or
insert the entry), while the per-key Mutex serializes concurrent same-key
calls to parse(). This prevents the remove-and-reinsert race where two
threads would both create default state for the same key, losing one
thread’s HPACK table.
Implementations§
Source§impl<K: Hash + Eq + Clone> H2SessionCache<K>
impl<K: Hash + Eq + Clone> H2SessionCache<K>
Sourcepub fn parse(
&self,
key: K,
buffer: &[u8],
) -> Result<HashMap<StreamId, ParsedH2Message>, ParseError>
pub fn parse( &self, key: K, buffer: &[u8], ) -> Result<HashMap<StreamId, ParsedH2Message>, ParseError>
Parse buffer with connection state
If the connection key doesn’t exist, creates new state automatically. Returns completed HTTP/2 messages indexed by stream_id. The map may be empty if no streams completed yet — this is not an error.
Sourcepub fn remove(&self, key: &K) -> Option<H2ConnectionState>
pub fn remove(&self, key: &K) -> Option<H2ConnectionState>
Remove connection state (call when connection closes)
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for H2SessionCache<K>
impl<K> !RefUnwindSafe for H2SessionCache<K>
impl<K> Send for H2SessionCache<K>where
K: Send,
impl<K> Sync for H2SessionCache<K>
impl<K> Unpin for H2SessionCache<K>
impl<K> UnsafeUnpin for H2SessionCache<K>
impl<K> UnwindSafe for H2SessionCache<K>where
K: UnwindSafe,
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