pub struct Protocol;Expand description
Protocol handler for Claude Code JSON lines communication
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn serialize<T: Serialize>(message: &T) -> Result<String>
pub fn serialize<T: Serialize>(message: &T) -> Result<String>
Serialize a message to JSON lines format
Sourcepub fn deserialize<T: for<'de> Deserialize<'de>>(line: &str) -> Result<T>
pub fn deserialize<T: for<'de> Deserialize<'de>>(line: &str) -> Result<T>
Deserialize a JSON line into a message
Sourcepub fn write_sync<W: Write, T: Serialize>(
writer: &mut W,
message: &T,
) -> Result<()>
pub fn write_sync<W: Write, T: Serialize>( writer: &mut W, message: &T, ) -> Result<()>
Write a message to a synchronous writer
Sourcepub fn read_sync<R: BufRead, T: for<'de> Deserialize<'de>>(
reader: &mut R,
) -> Result<T>
pub fn read_sync<R: BufRead, T: for<'de> Deserialize<'de>>( reader: &mut R, ) -> Result<T>
Read a message from a synchronous reader
Sourcepub async fn write_async<W: AsyncWriteExt + Unpin, T: Serialize>(
writer: &mut W,
message: &T,
) -> Result<()>
pub async fn write_async<W: AsyncWriteExt + Unpin, T: Serialize>( writer: &mut W, message: &T, ) -> Result<()>
Write a message to an async writer
Sourcepub async fn read_async<R: AsyncBufReadExt + Unpin, T: for<'de> Deserialize<'de>>(
reader: &mut R,
) -> Result<T>
pub async fn read_async<R: AsyncBufReadExt + Unpin, T: for<'de> Deserialize<'de>>( reader: &mut R, ) -> Result<T>
Read a message from an async reader
Auto Trait Implementations§
impl Freeze for Protocol
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnwindSafe for Protocol
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