[−][src]Struct qrpc_sdk::RpcSocket
A qrpc connection wrapper
This type wraps a UNIX socket connection to a remote client. By default it is configured in client-only mode, meaning that the only time it listens for incoming messages is when waiting for a reply from the rpc broker, libqaul, or another service. To pro-actively reply to incoming requests (for example, if you want that your service can be used by other services)
Implementations
impl RpcSocket
[src]
pub fn new<P: AsRef<Path>>(path: P) -> Result<Arc<Self>>
[src]
Connect to an established socket to the RPC system
To listen for new connections you need to explicitly call
listen(...)
, otherwise it will only act as a sending socket,
where each reply is meant for one request.
pub fn create<P, F>(path: P, handle_connection: F) -> Result<Arc<Self>> where
P: AsRef<Path>,
F: Fn(Socket, SockAddr) + Send + Sync + 'static,
[src]
P: AsRef<Path>,
F: Fn(Socket, SockAddr) + Send + Sync + 'static,
Create a new QRPC socket. This function is meant for servers
Because creating the socket is synonymous with listening for
connections on it, this function wraps both new
(sort of),
and listen
, meaning that you must provide a closure at
this point.
pub fn with_duration<P: AsRef<Path>>(
path: P,
timeout: Duration
) -> Result<Arc<Self>>
[src]
path: P,
timeout: Duration
) -> Result<Arc<Self>>
Create a new socket with an explicit timeout duration
Setup is the same as when calling new
, except that you can
choose an explicit timeout, instead of the default.
pub fn listen<F>(self: &Arc<Self>, fut: F) where
F: Future<Output = ()> + Send + 'static,
[src]
F: Future<Output = ()> + Send + 'static,
Start listening for connections with a future
Incoming messages need to be parsed by your service, and then replied to.
pub async fn send_msg<'s, F: 'static, T, S, M: 's>(
self: &'s Arc<Self>,
target: S,
msg: Vec<u8>,
handle: F
) -> RpcResult<T> where
F: Fn(MsgReader<'s, M>) -> RpcResult<T> + Send,
S: Into<String>,
M: FromPointerReader<'s>,
[src]
self: &'s Arc<Self>,
target: S,
msg: Vec<u8>,
handle: F
) -> RpcResult<T> where
F: Fn(MsgReader<'s, M>) -> RpcResult<T> + Send,
S: Into<String>,
M: FromPointerReader<'s>,
Send a binary payload message to a specific service.
This function needs to be called by your service when mapping your public API to the RPC layer. Internally all requests will be proxied, and parsed by your service backend.
Use the message builder functions available in io
to
construct a correctly packed and compressed message.
In order to react to the response sent by the other side, you need to provide a future to be run.
pub fn running(&self) -> bool
[src]
Check if the socket is still running
Use this function in your service's listening code to determine whether the connection should be shut-down
pub fn listening(&self) -> bool
[src]
Query whether this socket is listening for connections
Auto Trait Implementations
impl RefUnwindSafe for RpcSocket
impl Send for RpcSocket
impl Sync for RpcSocket
impl Unpin for RpcSocket
impl UnwindSafe for RpcSocket
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,