Skip to main content

ProtocolHandler

Struct ProtocolHandler 

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

Protocol handler for managing control protocol communication

Implementations§

Source§

impl ProtocolHandler

Source

pub fn new() -> Self

Create a new protocol handler

Source

pub fn set_hook_channel(&mut self, tx: UnboundedSender<(String, HookEvent)>)

Set hook callback channel

Source

pub fn set_permission_channel( &mut self, tx: UnboundedSender<(RequestId, PermissionRequest)>, )

Set permission callback channel

Source

pub fn is_initialized(&self) -> bool

Check if protocol is initialized

Source

pub fn set_initialized(&self, value: bool)

Set protocol as initialized (for cases where no handshake is needed)

Source

pub fn create_init_request(&self) -> InitRequest

Create initialization request

Source

pub fn handle_init_response(&self, response: InitResponse) -> Result<()>

Handle initialization response

Source

pub async fn send_request( &self, request: ControlRequest, ) -> Result<Receiver<ControlResponse>>

Send a request and wait for response

Source

pub async fn handle_response(&self, response: ControlResponse) -> Result<()>

Handle incoming control response

Source

pub fn create_interrupt_request(&self) -> ControlRequest

Create interrupt request

Source

pub fn create_send_message_request(&self, content: String) -> ControlRequest

Create send message request

Source

pub fn create_hook_response( &self, hook_id: String, response: Value, ) -> ControlRequest

Create hook response

Source

pub fn create_permission_response( &self, request_id: RequestId, result: PermissionResult, ) -> ControlRequest

Create permission response

Source

pub fn serialize_message(&self, message: &ControlMessage) -> Result<String>

Serialize control message to JSON

Source

pub fn deserialize_message(&self, json: &str) -> Result<ControlMessage>

Deserialize control message from JSON

Trait Implementations§

Source§

impl Default for ProtocolHandler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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.