Skip to main content

Context

Struct Context 

Source
pub struct Context(/* private fields */);

Implementations§

Source§

impl Context

Source

pub fn connect() -> Option<Self>

Source

pub fn get_backend(&self) -> Result<LibsessionBackend>

Source

pub fn get_session(&self) -> Result<Session>

Retrieves the session ID for the current process.

§Errors

Returns Error::NotFound if the backend cannot resolve the session, or Error::InternalError if it returns a null session ID.

Source

pub fn get_session_for_pid(&self, pid: i32) -> Result<Session>

Retrieves the session ID for a process.

§Errors

Returns Error::NotFound if the backend cannot resolve the session, or Error::InternalError if it returns a null ID.

Source

pub fn get_display_for_uid(&self, uid: u32) -> Result<Session>

Source

pub fn list_sessions(&self) -> Result<Vec<Session>>

Source

pub fn is_session_local(&self, session: &Session) -> Result<bool>

Source

pub fn get_owner_uid_for_pid(&self, pid: i32) -> Result<u32>

Source

pub fn get_user_state(&self, uid: u32) -> Result<LibsessionUserState>

Source

pub fn get_session_uid(&self, session: &Session) -> Result<u32>

Source

pub fn get_session_state( &self, session: &Session, ) -> Result<LibsessionSessionState>

Source

pub fn is_session_active(&self, session: &Session) -> Result<bool>

Source

pub unsafe fn set_log_fn(&self, callback: LibsessionLogFn) -> Result<()>

Sets the logging callback, or disables callbacks with None.

§Errors

Returns an error if the underlying call fails.

§Safety

The callback must remain callable until replaced or this context is dropped. It must not unwind or access this context reentrantly. The message pointer is valid only during the callback; it must not be retained or freed.

Source

pub fn set_log_level(&self, level: LibsessionLogLevel) -> Result<()>

Sets the logging level. Off disables logging.

§Errors

Returns an error if the underlying call fails.

Source

pub fn get_log_level(&self) -> LibsessionLogLevel

Retrieves the current logging level.

Source

pub fn get_monitor(&mut self) -> Result<Monitor>

Creates a monitor for session changes.

§Errors

Returns Error::Unavailable if the backend cannot create a monitor.

Trait Implementations§

Source§

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more