pub trait UnixConnectionExt: IsA<UnixConnection> + 'static {
// Provided methods
fn receive_credentials(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Credentials, Error> { ... }
fn receive_credentials_async<P>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
where P: FnOnce(Result<Credentials, Error>) + 'static { ... }
fn receive_credentials_future(
&self,
) -> Pin<Box<dyn Future<Output = Result<Credentials, Error>>>> { ... }
fn receive_fd(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<i32, Error> { ... }
fn send_credentials(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
fn send_credentials_async<P>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
where P: FnOnce(Result<(), Error>) + 'static { ... }
fn send_credentials_future(
&self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> { ... }
fn send_fd(
&self,
fd: i32,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error> { ... }
}Expand description
Provided Methods§
Sourcefn receive_credentials(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Credentials, Error>
fn receive_credentials( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<Credentials, Error>
Receives credentials from the sending end of the connection. The sending end has to call g_unix_connection_send_credentials() (or similar) for this to work.
As well as reading the credentials this also reads (and discards) a single byte from the stream, as this is required for credentials passing to work on some implementations.
This method can be expected to be available on the following platforms:
- Linux since GLib 2.26
- FreeBSD since GLib 2.26
- GNU/kFreeBSD since GLib 2.36
- Solaris, Illumos and OpenSolaris since GLib 2.40
- GNU/Hurd since GLib 2.40
Other ways to exchange credentials with a foreign peer includes the #GUnixCredentialsMessage type and g_socket_get_credentials() function.
§cancellable
A #GCancellable or None.
§Returns
Received credentials on success (free with
g_object_unref()), None if @error is set.
Sourcefn receive_credentials_async<P>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn receive_credentials_async<P>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously receive credentials.
For more details, see g_unix_connection_receive_credentials() which is the synchronous version of this call.
When the operation is finished, @callback will be called. You can then call g_unix_connection_receive_credentials_finish() to get the result of the operation.
§cancellable
optional #GCancellable object, None to ignore.
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn receive_credentials_future( &self, ) -> Pin<Box<dyn Future<Output = Result<Credentials, Error>>>>
Sourcefn receive_fd(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<i32, Error>
fn receive_fd( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<i32, Error>
Receives a file descriptor from the sending end of the connection. The sending end has to call g_unix_connection_send_fd() for this to work.
As well as reading the fd this also reads a single byte from the stream, as this is required for fd passing to work on some implementations.
§cancellable
optional #GCancellable object, None to ignore
§Returns
a file descriptor on success, -1 on error.
Sourcefn send_credentials(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn send_credentials( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Passes the credentials of the current user the receiving side of the connection. The receiving end has to call g_unix_connection_receive_credentials() (or similar) to accept the credentials.
As well as sending the credentials this also writes a single NUL byte to the stream, as this is required for credentials passing to work on some implementations.
This method can be expected to be available on the following platforms:
- Linux since GLib 2.26
- FreeBSD since GLib 2.26
- GNU/kFreeBSD since GLib 2.36
- Solaris, Illumos and OpenSolaris since GLib 2.40
- GNU/Hurd since GLib 2.40
Other ways to exchange credentials with a foreign peer includes the #GUnixCredentialsMessage type and g_socket_get_credentials() function.
§cancellable
A #GCancellable or None.
§Returns
Sourcefn send_credentials_async<P>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn send_credentials_async<P>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously send credentials.
For more details, see g_unix_connection_send_credentials() which is the synchronous version of this call.
When the operation is finished, @callback will be called. You can then call g_unix_connection_send_credentials_finish() to get the result of the operation.
§cancellable
optional #GCancellable object, None to ignore.
§callback
a #GAsyncReadyCallback to call when the request is satisfied
fn send_credentials_future( &self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>
Sourcefn send_fd(
&self,
fd: i32,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
fn send_fd( &self, fd: i32, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Passes a file descriptor to the receiving side of the connection. The receiving end has to call g_unix_connection_receive_fd() to accept the file descriptor.
As well as sending the fd this also writes a single byte to the stream, as this is required for fd passing to work on some implementations.
§fd
a file descriptor
§cancellable
optional #GCancellable object, None to ignore.
§Returns
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".