pub struct RpcConn { /* private fields */ }
Expand description
An open RPC connection to Arti.
Implementations§
Source§impl RpcConn
impl RpcConn
Sourcepub fn open_stream_as_object(
&self,
on_object: Option<&ObjectId>,
target: (&str, u16),
isolation: &str,
) -> Result<(ObjectId, TcpStream), StreamError>
pub fn open_stream_as_object( &self, on_object: Option<&ObjectId>, target: (&str, u16), isolation: &str, ) -> Result<(ObjectId, TcpStream), StreamError>
Open a new data stream, registering the stream with the RPC system.
Behaves the same as open_stream()
,
with the following exceptions:
- Returns a
ObjectId
that can be used to identify theDataStream
for later RPC requests. - Tells Arti not to wait for the stream to succeed or fail over the Tor network. (To wait for the stream to succeed or fail, use the appropriate method.)
(TODO RPC: Implement such a method!)
Sourcepub fn open_stream(
&self,
on_object: Option<&ObjectId>,
(hostname, port): (&str, u16),
isolation: &str,
) -> Result<TcpStream, StreamError>
pub fn open_stream( &self, on_object: Option<&ObjectId>, (hostname, port): (&str, u16), isolation: &str, ) -> Result<TcpStream, StreamError>
Open a new data stream, using Arti to connect anonymously to a given address and port.
If on_object
is provided, it must be a an ID for a client-like RPC
object that supports opening data streams. If it is not provided,
the data stream is opened relative to the current session.
We tell Arti that the stream must not share
a circuit with any other stream with a different value for isolation
.
(If your application doesn’t care about isolating its streams from one another,
it is acceptable to leave isolation
as an empty string.)
Source§impl RpcConn
impl RpcConn
Sourcepub fn session(&self) -> Option<&ObjectId>
pub fn session(&self) -> Option<&ObjectId>
Return the ObjectId for the negotiated Session.
Nearly all RPC methods require a Session, or some other object accessed via the session.
(This function will only return None if no authentication has been performed. TODO RPC: It is not currently possible to make an unauthenticated connection.)
Sourcepub fn execute(
&self,
cmd: &str,
) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
pub fn execute( &self, cmd: &str, ) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
Run a command, and wait for success or failure.
Note that this function will return Err(.)
only if sending the command or getting a
response failed. If the command was sent successfully, and Arti reported an error in response,
this function returns Ok(Err(.))
.
Note that the command does not need to include an id
field. If you omit it,
one will be generated.
Sourcepub fn cancel(&self, request_id: &AnyRequestId) -> Result<(), ProtoError>
pub fn cancel(&self, request_id: &AnyRequestId) -> Result<(), ProtoError>
Cancel a request by ID.
Sourcepub fn execute_with_handle(
&self,
cmd: &str,
) -> Result<RequestHandle, ProtoError>
pub fn execute_with_handle( &self, cmd: &str, ) -> Result<RequestHandle, ProtoError>
Like execute
, but don’t wait. This lets the caller see the
request ID and maybe cancel it.
Sourcepub fn execute_with_updates<F>(
&self,
cmd: &str,
update_cb: F,
) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
pub fn execute_with_updates<F>( &self, cmd: &str, update_cb: F, ) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
As execute(), but run update_cb for every update we receive.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RpcConn
impl RefUnwindSafe for RpcConn
impl Send for RpcConn
impl Sync for RpcConn
impl Unpin for RpcConn
impl UnwindSafe for RpcConn
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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