pub struct Session { /* private fields */ }Expand description
An open session.
Implementations§
Source§impl Session
impl Session
Sourcepub async fn login(
client: Client,
username: &str,
password: &SecretString,
) -> Result<Self, Error>
pub async fn login( client: Client, username: &str, password: &SecretString, ) -> Result<Self, Error>
Logs in with the user and the password. client is a client for the
web interface, without credentials. Sends the password only as the
answer to the challenge, and logs in at most once.
§Errors
Error::Blocked if the device blocks logins, Error::Rejected
if it rejects the login, and the errors of the requests.
Sourcepub fn rights(&self) -> &[Right]
pub fn rights(&self) -> &[Right]
What the user may do in the web interface, like HomeAuto: read.
Sourcepub async fn get(&self, path: &str) -> Result<String, Error>
pub async fn get(&self, path: &str) -> Result<String, Error>
Fetches a document of the REST API, like
/api/v0/smarthome/overview, with the session.
§Errors
The errors of the request.
Sourcepub async fn post(
&self,
path: &str,
form: &[(&str, &str)],
) -> Result<String, Error>
pub async fn post( &self, path: &str, form: &[(&str, &str)], ) -> Result<String, Error>
Posts a form to a page of the web interface, like /data.lua, with
the session ID added as the field sid.
§Errors
The errors of the request.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl !UnwindSafe for Session
impl Forget for Session
impl Move for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more