Struct zbus::ConnectionBuilder

source ·
pub struct ConnectionBuilder<'a> { /* private fields */ }
Expand description

A builder for zbus::Connection.

Implementations§

source§

impl<'a> ConnectionBuilder<'a>

source

pub fn session() -> Result<Self>

Create a builder for the session/user message bus connection.

source

pub fn system() -> Result<Self>

Create a builder for the system-wide message bus connection.

source

pub fn address<A>(address: A) -> Result<Self>where A: TryInto<Address>, A::Error: Into<Error>,

Create a builder for connection that will use the given D-Bus bus address.

source

pub fn unix_stream(stream: UnixStream) -> Self

Create a builder for connection that will use the given unix stream.

If the default async-io feature is disabled, this method will expect tokio::net::UnixStream argument.

source

pub fn tcp_stream(stream: TcpStream) -> Self

Create a builder for connection that will use the given TCP stream.

If the default async-io feature is disabled, this method will expect tokio::net::TcpStream argument.

source

pub fn vsock_stream(stream: VsockStream) -> Self

Create a builder for connection that will use the given VSOCK stream.

This method is only available when either vsock or tokio-vsock feature is enabled. The type of stream is vsock::VsockStream with vsock feature and tokio_vsock::VsockStream with tokio-vsock feature.

source

pub fn socket<S: Socket + 'static>(socket: S) -> Self

Create a builder for connection that will use the given socket.

source

pub fn auth_mechanisms(self, auth_mechanisms: &[AuthMechanism]) -> Self

Specify the mechanisms to use during authentication.

source

pub fn p2p(self) -> Self

The to-be-created connection will be a peer-to-peer connection.

source

pub fn server(self, guid: &'a Guid) -> Self

The to-be-created connection will be a server using the given GUID.

The to-be-created connection will wait for incoming client authentication handshake and negotiation messages, for peer-to-peer communications after successful creation.

source

pub fn max_queued(self, max: usize) -> Self

Set the capacity of the main (unfiltered) queue.

Since typically you’d want to set this at instantiation time, you can set it through the builder.

Example
let conn = ConnectionBuilder::session()?
    .max_queued(30)
    .build()
    .await?;
assert_eq!(conn.max_queued(), 30);

// Do something useful with `conn`..
source

pub fn internal_executor(self, enabled: bool) -> Self

Enable or disable the internal executor thread.

The thread is enabled by default.

See Connection::executor for more details.

source

pub fn serve_at<P, I>(self, path: P, iface: I) -> Result<Self>where I: Interface, P: TryInto<ObjectPath<'a>>, P::Error: Into<Error>,

Register a D-Bus Interface to be served at a given path.

This is similar to zbus::ObjectServer::at, except that it allows you to have your interfaces available immediately after the connection is established. Typically, this is exactly what you’d want. Also in contrast to zbus::ObjectServer::at, this method will replace any previously added interface with the same name at the same path.

source

pub fn name<W>(self, well_known_name: W) -> Result<Self>where W: TryInto<WellKnownName<'a>>, W::Error: Into<Error>,

Register a well-known name for this connection on the bus.

This is similar to zbus::Connection::request_name, except the name is requested as part of the connection setup (ConnectionBuilder::build), immediately after interfaces registered (through ConnectionBuilder::serve_at) are advertised. Typically this is exactly what you want.

source

pub fn unique_name<U>(self, unique_name: U) -> Result<Self>where U: TryInto<UniqueName<'a>>, U::Error: Into<Error>,

Sets the unique name of the connection.

Panics

This method panics if the to-be-created connection is not a peer-to-peer connection. It will always panic if the connection is to a message bus as it’s the bus that assigns peers their unique names. This is mainly provided for bus implementations. All other users should not need to use this method.

source

pub async fn build(self) -> Result<Connection>

Build the connection, consuming the builder.

Errors

Until server-side bus connection is supported, attempting to build such a connection will result in Error::Unsupported error.

Trait Implementations§

source§

impl<'a> Debug for ConnectionBuilder<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ConnectionBuilder<'a>

§

impl<'a> Send for ConnectionBuilder<'a>

§

impl<'a> Sync for ConnectionBuilder<'a>

§

impl<'a> Unpin for ConnectionBuilder<'a>

§

impl<'a> !UnwindSafe for ConnectionBuilder<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere U: From<T>,

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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