Struct zbus::ConnectionBuilder
source · [−]pub struct ConnectionBuilder<'a> { /* private fields */ }
Expand description
A builder for zbus::Connection
.
Implementations
sourceimpl<'a> ConnectionBuilder<'a>
impl<'a> ConnectionBuilder<'a>
sourcepub fn address<A>(address: A) -> Result<Self> where
A: TryInto<Address>,
A::Error: Into<Error>,
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.
sourcepub fn unix_stream(stream: UnixStream) -> Self
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.
sourcepub fn tcp_stream(stream: TcpStream) -> Self
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.
sourcepub fn socket<S: Socket + 'static>(socket: S) -> Self
pub fn socket<S: Socket + 'static>(socket: S) -> Self
Create a builder for connection that will use the given socket.
sourcepub fn auth_mechanisms(self, auth_mechanisms: &[AuthMechanism]) -> Self
pub fn auth_mechanisms(self, auth_mechanisms: &[AuthMechanism]) -> Self
Specify the mechanisms to use during authentication.
sourcepub fn server(self, guid: &'a Guid) -> Self
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.
sourcepub fn max_queued(self, max: usize) -> Self
pub fn max_queued(self, max: usize) -> Self
Set the max number of messages to 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`..
sourcepub fn internal_executor(self, enabled: bool) -> Self
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.
sourcepub fn serve_at<P, I>(self, path: P, iface: I) -> Result<Self> where
I: Interface,
P: TryInto<ObjectPath<'a>>,
P::Error: Into<Error>,
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.
sourcepub fn name<W>(self, well_known_name: W) -> Result<Self> where
W: TryInto<WellKnownName<'a>>,
W::Error: Into<Error>,
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.
sourcepub async fn build(self) -> Result<Connection>
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
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more