Struct zbus::blocking::connection::Builder

source ·
pub struct Builder<'a>(/* private fields */);
Expand description

Implementations§

source§

impl<'a> Builder<'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.

Since tokio currently does not support Unix domain sockets on Windows, this method is not available when the tokio feature is enabled and building for Windows target.

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 authenticated_socket<S, G>(socket: S, guid: G) -> Result<Self>
where S: Into<BoxedSplit>, G: TryInto<Guid<'a>>, G::Error: Into<Error>,

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

This is similar to Builder::socket, except that the socket is either already authenticated or does not require authentication.

source

pub fn socket<S: Into<BoxedSplit>>(socket: S) -> Self

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

source

pub fn auth_mechanism(self, auth_mechanism: AuthMechanism) -> Self

Specify the mechanism to use during authentication.

source

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

👎Deprecated since 4.1.3: Use auth_mechanism instead.

Specify the mechanisms to use during authentication.

source

pub fn cookie_context<C>(self, context: C) -> Result<Self>
where C: Into<Str<'a>>,

The cookie context to use during authentication.

This is only used when the cookie authentication mechanism is enabled and only valid for server connection.

If not specified, the default cookie context of org_freedesktop_general will be used.

§Errors

If the given string is not a valid cookie context.

source

pub fn cookie_id(self, id: usize) -> Self

The ID of the cookie to use during authentication.

This is only used when the cookie authentication mechanism is enabled and only valid for server connection.

If not specified, the first cookie found in the cookie context file will be used.

source

pub fn p2p(self) -> Self

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

This method is only available when the p2p feature is enabled.

source

pub fn server<G>(self, guid: G) -> Result<Self>
where G: TryInto<Guid<'a>>, G::Error: Into<Error>,

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.

This method is only available when the p2p feature is enabled.

NOTE: This method is redundant when using Builder::authenticated_socket since the latter already sets the GUID for the connection and zbus doesn’t differentiate between a server and a client connection, except for authentication.

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 = connection::Builder::session()?
    .max_queued(30)
    .build()?;
assert_eq!(conn.max_queued(), 30);

// Do something useful with `conn`..
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::blocking::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::blocking::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::blocking::Connection::request_name, except the name is requested as part of the connection setup (Builder::build), immediately after interfaces registered (through Builder::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.

This method is only available when the bus-impl feature is enabled.

§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 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 Builder<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Builder<'a>

§

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

§

impl<'a> Send for Builder<'a>

§

impl<'a> Sync for Builder<'a>

§

impl<'a> Unpin for Builder<'a>

§

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

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> 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 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

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

source§

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