pub struct XCBConnection<Conn = XcbConnectionWrapper> { /* private fields */ }
Expand description
A connection to an X11 server.
This type wraps *mut xcb_connection_t
that is provided by libxcb. It provides a rust
interface to this C library.
Implementations§
Source§impl XCBConnection
impl XCBConnection
Sourcepub fn connect(
dpy_name: Option<&CStr>,
) -> Result<(XCBConnection, usize), ConnectError>
pub fn connect( dpy_name: Option<&CStr>, ) -> Result<(XCBConnection, usize), ConnectError>
Establish a new connection to an X11 server.
If a dpy_name
is provided, it describes the display that should be connected to, for
example 127.0.0.1:1
. If no value is provided, the $DISPLAY
environment variable is
used.
Sourcepub unsafe fn from_raw_xcb_connection(
ptr: *mut c_void,
should_drop: bool,
) -> Result<XCBConnection, ConnectError>
pub unsafe fn from_raw_xcb_connection( ptr: *mut c_void, should_drop: bool, ) -> Result<XCBConnection, ConnectError>
Create a connection wrapper for a raw libxcb xcb_connection_t
.
xcb_disconnect
is called on drop only if should_drop
is true
.
If this function returns an Err()
and should_drop
was true, then
xcb_disconnect
was already called.
§Safety
If should_drop
is false
, the connection must live longer than the returned
XCBConnection
. If should_drop
is true
, the returned XCBConnection
will
take the ownership of the connection.
Source§impl<Conn: AsRawXcbConnection> XCBConnection<Conn>
impl<Conn: AsRawXcbConnection> XCBConnection<Conn>
Sourcepub fn from_existing_connection(conn: Conn) -> Result<Self, ConnectError>
pub fn from_existing_connection(conn: Conn) -> Result<Self, ConnectError>
Create an XCBConnection
from an object that implements AsRawXcbConnection
.
Sourcepub fn inner_connection(&self) -> &Conn
pub fn inner_connection(&self) -> &Conn
Get a reference to the inner managed connection.
It is discouraged to use this inner connection for fetching events.
Sourcepub fn has_error(&self) -> Option<ConnectionError>
pub fn has_error(&self) -> Option<ConnectionError>
Check if the underlying XCB connection is in an error state.
Sourcepub fn get_raw_xcb_connection(&self) -> *mut c_void
pub fn get_raw_xcb_connection(&self) -> *mut c_void
Get access to the raw libxcb xcb_connection_t
.
The returned pointer is valid for as long as the original object was not dropped. No ownerhsip is transferred.