pub struct Context(/* private fields */);Implementations§
Source§impl Context
impl Context
pub fn connect() -> Option<Self>
pub fn get_backend(&self) -> Result<LibsessionBackend>
Sourcepub fn get_session(&self) -> Result<Session>
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.
Sourcepub fn get_session_for_pid(&self, pid: i32) -> Result<Session>
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.
pub fn get_display_for_uid(&self, uid: u32) -> Result<Session>
pub fn list_sessions(&self) -> Result<Vec<Session>>
pub fn is_session_local(&self, session: &Session) -> Result<bool>
pub fn get_owner_uid_for_pid(&self, pid: i32) -> Result<u32>
pub fn get_user_state(&self, uid: u32) -> Result<LibsessionUserState>
pub fn get_session_uid(&self, session: &Session) -> Result<u32>
pub fn get_session_state( &self, session: &Session, ) -> Result<LibsessionSessionState>
pub fn is_session_active(&self, session: &Session) -> Result<bool>
Sourcepub unsafe fn set_log_fn(&self, callback: LibsessionLogFn) -> Result<()>
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.
Sourcepub fn set_log_level(&self, level: LibsessionLogLevel) -> Result<()>
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.
Sourcepub fn get_log_level(&self) -> LibsessionLogLevel
pub fn get_log_level(&self) -> LibsessionLogLevel
Retrieves the current logging level.
Sourcepub fn get_monitor(&mut self) -> Result<Monitor>
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.