Connection

Struct Connection 

Source
pub struct Connection {
    pub reader: Option<BufReader<Box<dyn Read + Send + Sync>>>,
    pub writer: Option<Box<dyn Write + Send + Sync>>,
    pub stream: Option<Box<dyn Stream>>,
    pub child: Option<Child>,
    pub tempdir: Option<TempDir>,
    /* private fields */
}
Expand description

A client connection builder to a varlink service.

Fields§

§reader: Option<BufReader<Box<dyn Read + Send + Sync>>>§writer: Option<Box<dyn Write + Send + Sync>>§stream: Option<Box<dyn Stream>>§child: Option<Child>§tempdir: Option<TempDir>

Implementations§

Source§

impl Connection

Source

pub fn new<S: ?Sized + AsRef<str>>(address: &S) -> Result<Arc<RwLock<Self>>>

Create a connection with a varlink URI

see with_address

Source

pub fn with_address<S: ?Sized + AsRef<str>>( address: &S, ) -> Result<Arc<RwLock<Self>>>

Create a connection with a varlink URI

following the varlink address specification.

Currently supported address URIs are:

  • TCP tcp:127.0.0.1:12345 hostname/IP address and port
  • UNIX socket unix:/run/org.example.ftl
  • UNIX abstract namespace socket unix:@org.example.ftl (on Linux only)
§Examples
let connection = Connection::with_address("unix:/tmp/org.example.myservice");
let connection = Connection::with_address("tcp:127.0.0.1:12345");
Source

pub fn with_address_no_rw<S: ?Sized + AsRef<str>>( address: &S, ) -> Result<Arc<RwLock<Self>>>

Source

pub fn with_activate<S: ?Sized + AsRef<str>>( command: &S, ) -> Result<Arc<RwLock<Self>>>

Create a connection to a service, which is executed in the background.

Create a connection to a service, which is started with command and passed a socket pair via socket activation. The address of the unix socket is set in the environment variable VARLINK_ADDRESS. Additionally the socket activation variables LISTEN_FDS=1, LISTEN_FDNAMES=varlink and LISTEN_PID are set.

§Examples
let connection = Connection::with_activate("myservice --varlink=$VARLINK_ADDRESS");
Source

pub fn with_activate_no_rw<S: ?Sized + AsRef<str>>( command: &S, ) -> Result<Arc<RwLock<Self>>>

Source

pub fn with_bridge<S: ?Sized + AsRef<str>>( command: &S, ) -> Result<Arc<RwLock<Self>>>

Create a connection to a service via stdin/stdout of a specified command.

Create a “bridge” to e.g. another host via ssh or other connection commands. On the remote side varlink bridge is typically started. The connection will go through stdin/stdout of the command and the remote bridge command will multiplex to the wanted varlink services.

Of course with ssh there are better options, like unix socket forwarding -L local_socket:remote_socket.

§Examples
let connection = Connection::with_bridge("ssh my.example.org -- varlink bridge");
Source

pub fn with_bridge_no_rw<S: ?Sized + AsRef<str>>( command: &S, ) -> Result<Arc<RwLock<Self>>>

Source

pub fn address(&self) -> String

Return the address used by the connection.

Only useful, if you want to clone a connection built with_activate or with_address

Trait Implementations§

Source§

impl Default for Connection

Source§

fn default() -> Connection

Returns the “default value” for a type. Read more
Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. 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
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.

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