pub struct CounterWrapper<C: RequestConnection>(/* private fields */);Expand description
A RAII-like wrapper around a Counter.
Instances of this struct represent a Counter 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> CounterWrapper<C>
impl<C: RequestConnection> CounterWrapper<C>
Sourcepub fn for_counter(conn: C, id: Counter) -> Self
pub fn for_counter(conn: C, id: Counter) -> Self
Assume ownership of the given resource and destroy it in Drop.
Sourcepub fn into_counter(self) -> Counter
pub fn into_counter(self) -> Counter
Assume ownership of the XID of the wrapped resource
This function destroys this wrapper without freeing the underlying resource.
Source§impl<'c, C: X11Connection> CounterWrapper<&'c C>
impl<'c, C: X11Connection> CounterWrapper<&'c C>
Create a new Counter and return a Counter wrapper and a cookie.
This is a thin wrapper around create_counter that allocates an id for the Counter.
This function returns the resulting CounterWrapper that owns the created Counter and frees
it in Drop. This also returns a VoidCookie that comes from the call to
create_counter.
Errors can come from the call to X11Connection::generate_id or create_counter.
Source§impl<C: X11Connection> CounterWrapper<C>
impl<C: X11Connection> CounterWrapper<C>
Sourcepub fn create_counter(
conn: C,
initial_value: Int64,
) -> Result<Self, ReplyOrIdError>
pub fn create_counter( conn: C, initial_value: Int64, ) -> Result<Self, ReplyOrIdError>
Create a new Counter and return a Counter wrapper
This is a thin wrapper around create_counter that allocates an id for the Counter.
This function returns the resulting CounterWrapper that owns the created Counter and frees
it in Drop.
Errors can come from the call to X11Connection::generate_id or create_counter.