pub struct ProtocolHandler { /* private fields */ }Expand description
Protocol handler for managing control protocol communication
Implementations§
Source§impl ProtocolHandler
impl ProtocolHandler
Sourcepub fn set_hook_channel(&mut self, tx: UnboundedSender<(String, HookEvent)>)
pub fn set_hook_channel(&mut self, tx: UnboundedSender<(String, HookEvent)>)
Set hook callback channel
Sourcepub fn set_permission_channel(
&mut self,
tx: UnboundedSender<(RequestId, PermissionRequest)>,
)
pub fn set_permission_channel( &mut self, tx: UnboundedSender<(RequestId, PermissionRequest)>, )
Set permission callback channel
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if protocol is initialized
Sourcepub fn set_initialized(&self, value: bool)
pub fn set_initialized(&self, value: bool)
Set protocol as initialized (for cases where no handshake is needed)
Sourcepub fn create_init_request(&self) -> InitRequest
pub fn create_init_request(&self) -> InitRequest
Create initialization request
Sourcepub fn handle_init_response(&self, response: InitResponse) -> Result<()>
pub fn handle_init_response(&self, response: InitResponse) -> Result<()>
Handle initialization response
Sourcepub async fn send_request(
&self,
request: ControlRequest,
) -> Result<Receiver<ControlResponse>>
pub async fn send_request( &self, request: ControlRequest, ) -> Result<Receiver<ControlResponse>>
Send a request and wait for response
Sourcepub async fn handle_response(&self, response: ControlResponse) -> Result<()>
pub async fn handle_response(&self, response: ControlResponse) -> Result<()>
Handle incoming control response
Sourcepub fn create_interrupt_request(&self) -> ControlRequest
pub fn create_interrupt_request(&self) -> ControlRequest
Create interrupt request
Sourcepub fn create_send_message_request(&self, content: String) -> ControlRequest
pub fn create_send_message_request(&self, content: String) -> ControlRequest
Create send message request
Sourcepub fn create_hook_response(
&self,
hook_id: String,
response: Value,
) -> ControlRequest
pub fn create_hook_response( &self, hook_id: String, response: Value, ) -> ControlRequest
Create hook response
Sourcepub fn create_permission_response(
&self,
request_id: RequestId,
result: PermissionResult,
) -> ControlRequest
pub fn create_permission_response( &self, request_id: RequestId, result: PermissionResult, ) -> ControlRequest
Create permission response
Sourcepub fn serialize_message(&self, message: &ControlMessage) -> Result<String>
pub fn serialize_message(&self, message: &ControlMessage) -> Result<String>
Serialize control message to JSON
Sourcepub fn deserialize_message(&self, json: &str) -> Result<ControlMessage>
pub fn deserialize_message(&self, json: &str) -> Result<ControlMessage>
Deserialize control message from JSON
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ProtocolHandler
impl !UnwindSafe for ProtocolHandler
impl Freeze for ProtocolHandler
impl Send for ProtocolHandler
impl Sync for ProtocolHandler
impl Unpin for ProtocolHandler
impl UnsafeUnpin for ProtocolHandler
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> 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