Struct x11rb::protocol::record::ContextWrapper
source · pub struct ContextWrapper<C: RequestConnection>(/* private fields */);
Expand description
A RAII-like wrapper around a Context.
Instances of this struct represent a Context that is freed in Drop
.
Any errors during Drop
are silently ignored. Most likely an error here means that your
X11 connection is broken and later requests will also fail.
Implementations§
source§impl<C: RequestConnection> ContextWrapper<C>
impl<C: RequestConnection> ContextWrapper<C>
sourcepub fn for_context(conn: C, id: Context) -> Self
pub fn for_context(conn: C, id: Context) -> Self
Assume ownership of the given resource and destroy it in Drop
.
sourcepub fn into_context(self) -> Context
pub fn into_context(self) -> Context
Assume ownership of the XID of the wrapped resource
This function destroys this wrapper without freeing the underlying resource.
source§impl<'c, C: X11Connection> ContextWrapper<&'c C>
impl<'c, C: X11Connection> ContextWrapper<&'c C>
Create a new Context and return a Context wrapper and a cookie.
This is a thin wrapper around create_context that allocates an id for the Context.
This function returns the resulting ContextWrapper
that owns the created Context and frees
it in Drop
. This also returns a VoidCookie
that comes from the call to
create_context.
Errors can come from the call to X11Connection::generate_id or create_context.
source§impl<C: X11Connection> ContextWrapper<C>
impl<C: X11Connection> ContextWrapper<C>
sourcepub fn create_context(
conn: C,
element_header: ElementHeader,
client_specs: &[ClientSpec],
ranges: &[Range]
) -> Result<Self, ReplyOrIdError>
pub fn create_context( conn: C, element_header: ElementHeader, client_specs: &[ClientSpec], ranges: &[Range] ) -> Result<Self, ReplyOrIdError>
Create a new Context and return a Context wrapper
This is a thin wrapper around create_context that allocates an id for the Context.
This function returns the resulting ContextWrapper
that owns the created Context and frees
it in Drop
.
Errors can come from the call to X11Connection::generate_id or create_context.