Remove 'a lifetime for structs

This commit is contained in:
seanomik 2022-06-21 19:52:12 -04:00
parent ff628b05cf
commit e3e9e26be4
1 changed files with 14 additions and 14 deletions

View File

@ -1,20 +1,20 @@
use crate::{error::ClientError, TorrentInfo, TorrentTracker, TorrentUpload}; use crate::{error::ClientError, TorrentInfo, TorrentTracker, TorrentUpload};
pub struct ConnectionInfo<'a> { pub struct ConnectionInfo {
pub url: &'a str, pub url: String,
pub username: &'a str, pub username: String,
pub password: &'a str, pub password: String,
} }
pub type ClientResult<T> = Result<T, ClientError>; pub type ClientResult<T> = Result<T, ClientError>;
pub struct QBittorrentClient<'a> { pub struct QBittorrentClient {
client: reqwest::Client, client: reqwest::Client,
connection_info: Option<ConnectionInfo<'a>>, connection_info: Option<ConnectionInfo>,
auth_string: Option<String>, auth_string: Option<String>,
} }
impl<'a> QBittorrentClient<'a> { impl QBittorrentClient {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
client: reqwest::Client::new(), client: reqwest::Client::new(),
@ -24,12 +24,12 @@ impl<'a> QBittorrentClient<'a> {
} }
/// Login to qBittorrent. This must be ran so that the client can make requests. /// Login to qBittorrent. This must be ran so that the client can make requests.
pub async fn login(&mut self, url: &'a str, username: &'a str, password: &'a str) -> ClientResult<()> { pub async fn login(&mut self, url: &str, username: &str, password: &str) -> ClientResult<()> {
// Send response to get auth string // Send response to get auth string
let resp = self.client.post(format!("{}/api/v2/auth/login", url.clone())) let resp = self.client.post(format!("{}/api/v2/auth/login", url))
.form(&[ .form(&[
("username", username.clone()), ("username", username.to_string()),
("password", password.clone()), ("password", password.to_string()),
]) ])
.send().await?.error_for_status()?; .send().await?.error_for_status()?;
@ -47,9 +47,9 @@ impl<'a> QBittorrentClient<'a> {
// Store connection info // Store connection info
self.connection_info = Some(ConnectionInfo { self.connection_info = Some(ConnectionInfo {
url: url.clone(), url: url.to_string(),
username: username.clone(), username: username.to_string(),
password: password.clone(), password: password.to_string(),
}); });
Ok(()) Ok(())