Skip to main content

DcpContext

Struct DcpContext 

Source
pub struct DcpContext { /* private fields */ }
Expand description

Memory-mapped context for zero-copy sharing

Implementations§

Source§

impl DcpContext

Source

pub const MIN_SIZE: usize = ContextLayout::SIZE

Minimum buffer size

Source

pub fn new(conversation_id: u64) -> Self

Create a new context with the given conversation ID

Source

pub fn from_shared(buffer: Box<[u8]>) -> Result<Self, DCPError>

Create a context from existing shared memory

Source

pub fn as_bytes(&self) -> &[u8]

Get the raw buffer for sharing

Source

pub fn size(&self) -> usize

Get the buffer size

Source

pub fn conversation_id(&self) -> u64

Get the conversation ID

Source

pub fn message_count(&self) -> u64

Get the message count (atomic read)

Source

pub fn increment_message_count(&self) -> u64

Increment the message count atomically

Source

pub fn get_tool_state(&self, index: usize) -> Option<&ToolState>

Zero-copy access to tool state by index

Source

pub fn find_tool_state(&self, tool_id: u32) -> Option<&ToolState>

Find tool state by tool_id

Source

pub fn update_tool_state( &mut self, index: usize, state: &ToolState, ) -> Result<(), DCPError>

Atomic update with memory fence

§Safety

This function uses unsafe pointer operations but ensures memory safety through proper bounds checking and memory fencing.

Source

pub fn set_tool_state(&mut self, state: &ToolState) -> Result<usize, DCPError>

Update tool state by tool_id, finding or allocating a slot

Source

pub fn clear_tool_state(&mut self, index: usize) -> Result<(), DCPError>

Clear a tool state slot

Source

pub fn version(&self) -> u32

Get the version

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V