pub struct WshRpcProxy {
rpc_context: Arc<Mutex<Option<RpcContext>>>,
auth_token: Arc<Mutex<String>>,
pub to_remote: Sender<Vec<u8>>,
pub from_remote: Receiver<Vec<u8>>,
to_remote_rx: Option<Receiver<Vec<u8>>>,
from_remote_tx: Sender<Vec<u8>>,
}Expand description
Single-connection RPC proxy. Forwards messages between a local connection and a remote endpoint.
Fields§
§rpc_context: Arc<Mutex<Option<RpcContext>>>§auth_token: Arc<Mutex<String>>§to_remote: Sender<Vec<u8>>§from_remote: Receiver<Vec<u8>>§to_remote_rx: Option<Receiver<Vec<u8>>>§from_remote_tx: Sender<Vec<u8>>Implementations§
Source§impl WshRpcProxy
impl WshRpcProxy
pub fn new() -> Self
pub fn set_rpc_context(&self, ctx: RpcContext)
pub fn get_rpc_context(&self) -> Option<RpcContext>
pub fn set_auth_token(&self, token: &str)
pub fn get_auth_token(&self) -> String
Sourcepub fn take_to_remote_rx(&mut self) -> Option<Receiver<Vec<u8>>>
pub fn take_to_remote_rx(&mut self) -> Option<Receiver<Vec<u8>>>
Take the receiver end of to_remote channel (for proxy loop).
Sourcepub fn from_remote_sender(&self) -> Sender<Vec<u8>>
pub fn from_remote_sender(&self) -> Sender<Vec<u8>>
Get a clone of the from_remote sender (for injecting messages).
Sourcepub async fn send_to_remote(&self, msg: Vec<u8>) -> Result<(), String>
pub async fn send_to_remote(&self, msg: Vec<u8>) -> Result<(), String>
Send a message to the remote endpoint.
Sourcepub async fn send_rpc_message(&self, msg: &RpcMessage) -> Result<(), String>
pub async fn send_rpc_message(&self, msg: &RpcMessage) -> Result<(), String>
Inject an RPC message (encode as JSON and send to remote).
Auto Trait Implementations§
impl Freeze for WshRpcProxy
impl RefUnwindSafe for WshRpcProxy
impl Send for WshRpcProxy
impl Sync for WshRpcProxy
impl Unpin for WshRpcProxy
impl UnwindSafe for WshRpcProxy
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.