Struct RpcConn

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

An open RPC connection to Arti.

Implementations§

Source§

impl RpcConn

Source

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 the DataStream 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!)

Source

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

Source

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

Source

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.

Source

pub fn cancel(&self, request_id: &AnyRequestId) -> Result<(), ProtoError>

Cancel a request by ID.

Source

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.

Source

pub fn execute_with_updates<F>( &self, cmd: &str, update_cb: F, ) -> Result<Result<SuccessResponse, ErrorResponse>, ProtoError>
where F: FnMut(UpdateResponse) + Send + Sync,

As execute(), but run update_cb for every update we receive.

Trait Implementations§

Source§

impl Debug for RpcConn

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T