pub struct Builder<'a>(Builder<'a>);Expand description
A builder for zbus::blocking::Connection.
Tuple Fields§
§0: Builder<'a>Implementations§
Source§impl<'a> Builder<'a>
impl<'a> Builder<'a>
Sourcepub fn ibus() -> Result<Self>
pub fn ibus() -> Result<Self>
Create a builder for an IBus connection.
IBus (Intelligent Input Bus) is an input method framework. This method creates a builder
that will query the IBus daemon for its D-Bus address using the ibus address command.
§Platform Support
This method is available on Unix-like systems where IBus is installed.
§Errors
Returns an error if:
- The
ibuscommand is not found or fails to execute - The IBus daemon is not running
- The command output cannot be parsed as a valid D-Bus address
§Example
let _conn = connection::Builder::ibus()?
.build()?;
// Use the connection to interact with IBus services.Sourcepub fn address<A>(address: A) -> Result<Self>
pub fn address<A>(address: A) -> Result<Self>
Create a builder for a connection that will use the given D-Bus bus address.
Sourcepub fn async_io_unix_stream(stream: AsyncIoUnixStream) -> Self
pub fn async_io_unix_stream(stream: AsyncIoUnixStream) -> Self
Create a builder for a connection that will use the given unix stream.
The stream is a std::os::unix::net::UnixStream (or uds_windows::UnixStream on
Windows).
Sourcepub fn unix_stream(stream: UnixStream) -> Self
👎Deprecated since 5.19.0: Use async_io_unix_stream to avoid a build failure if the tokio feature gets enabled
pub fn unix_stream(stream: UnixStream) -> Self
Use async_io_unix_stream to avoid a build failure if the tokio feature gets enabled
Create a builder for a connection that will use the given unix stream.
This method expects a
tokio::net::UnixStream.
Without the tokio feature it accepts a std::os::unix::net::UnixStream instead, but
that form is deprecated in favor of
async_io_unix_stream.
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.
Sourcepub fn async_io_tcp_stream(stream: AsyncIoTcpStream) -> Self
pub fn async_io_tcp_stream(stream: AsyncIoTcpStream) -> Self
Create a builder for a connection that will use the given TCP stream.
The stream is a std::net::TcpStream.
Sourcepub fn tcp_stream(stream: TcpStream) -> Self
👎Deprecated since 5.19.0: Use async_io_tcp_stream to avoid a build failure if the tokio feature gets enabled
pub fn tcp_stream(stream: TcpStream) -> Self
Use async_io_tcp_stream to avoid a build failure if the tokio feature gets enabled
Create a builder for a connection that will use the given TCP stream.
This method expects a
tokio::net::TcpStream.
Without the tokio feature it accepts a std::net::TcpStream instead, but that form is
deprecated in favor of async_io_tcp_stream.
Sourcepub fn authenticated_socket<S, G>(socket: S, guid: G) -> Result<Self>
pub fn authenticated_socket<S, G>(socket: S, guid: G) -> Result<Self>
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.
Sourcepub fn socket<S: Into<BoxedSplit>>(socket: S) -> Self
pub fn socket<S: Into<BoxedSplit>>(socket: S) -> Self
Create a builder for a connection that will use the given socket.
Sourcepub fn auth_mechanism(self, auth_mechanism: AuthMechanism) -> Self
pub fn auth_mechanism(self, auth_mechanism: AuthMechanism) -> Self
Specify the mechanism to use during authentication.
Sourcepub fn user_id(self, id: u32) -> Self
pub fn user_id(self, id: u32) -> Self
Specify the user id during authentication.
This can be useful when using AuthMechanism::External with socat
to avoid the host decide what uid to use and instead provide one
known to have access rights.
Sourcepub fn max_queued(self, max: usize) -> Self
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`..Sourcepub fn serve_at<P, I>(self, path: P, iface: I) -> Result<Self>
pub fn serve_at<P, I>(self, path: P, iface: I) -> Result<Self>
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.
Sourcepub fn name<W>(self, well_known_name: W) -> Result<Self>
pub fn name<W>(self, well_known_name: W) -> Result<Self>
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.
Sourcepub fn allow_name_replacements(self, allow_replacement: bool) -> Self
pub fn allow_name_replacements(self, allow_replacement: bool) -> Self
Whether the zbus::fdo::RequestNameFlags::AllowReplacement flag will be set when
requesting names.
Sourcepub fn replace_existing_names(self, replace_existing: bool) -> Self
pub fn replace_existing_names(self, replace_existing: bool) -> Self
Whether the zbus::fdo::RequestNameFlags::ReplaceExisting flag will be set when
requesting names.
Sourcepub fn method_timeout(self, timeout: Duration) -> Self
pub fn method_timeout(self, timeout: Duration) -> Self
Set a timeout for method calls.
Method calls will return
zbus::Error::InputOutput(std::io::Error(kind: ErrorKind::TimedOut)) if a client does not
receive an answer from a service in time.
Sourcepub fn build(self) -> Result<Connection>
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 a Error::Unsupported error.