Tweak some things so that we can embed Web UI into Tauri
This commit is contained in:
parent
950ed816d1
commit
137d12cb9c
9 changed files with 105 additions and 44 deletions
|
|
@ -308,6 +308,22 @@ pub struct ApiAddTorrentResponse {
|
|||
}
|
||||
|
||||
pub struct OnlyFiles(Vec<usize>);
|
||||
pub struct InitialPeers(pub Vec<SocketAddr>);
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub struct TorrentAddQueryParams {
|
||||
pub overwrite: Option<bool>,
|
||||
pub output_folder: Option<String>,
|
||||
pub sub_folder: Option<String>,
|
||||
pub only_files_regex: Option<String>,
|
||||
pub only_files: Option<OnlyFiles>,
|
||||
pub peer_connect_timeout: Option<u64>,
|
||||
pub peer_read_write_timeout: Option<u64>,
|
||||
pub initial_peers: Option<InitialPeers>,
|
||||
// Will force interpreting the content as a URL.
|
||||
pub is_url: Option<bool>,
|
||||
pub list_only: Option<bool>,
|
||||
}
|
||||
|
||||
impl Serialize for OnlyFiles {
|
||||
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
|
||||
|
|
@ -348,8 +364,6 @@ impl<'de> Deserialize<'de> for OnlyFiles {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct InitialPeers(pub Vec<SocketAddr>);
|
||||
|
||||
impl<'de> Deserialize<'de> for InitialPeers {
|
||||
fn deserialize<D>(deserializer: D) -> std::prelude::v1::Result<Self, D::Error>
|
||||
where
|
||||
|
|
@ -378,23 +392,8 @@ impl Serialize for InitialPeers {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub struct TorrentAddQueryParams {
|
||||
pub overwrite: Option<bool>,
|
||||
pub output_folder: Option<String>,
|
||||
pub sub_folder: Option<String>,
|
||||
pub only_files_regex: Option<String>,
|
||||
pub only_files: Option<OnlyFiles>,
|
||||
pub peer_connect_timeout: Option<u64>,
|
||||
pub peer_read_write_timeout: Option<u64>,
|
||||
pub initial_peers: Option<InitialPeers>,
|
||||
// Will force interpreting the content as a URL.
|
||||
pub is_url: Option<bool>,
|
||||
pub list_only: Option<bool>,
|
||||
}
|
||||
|
||||
impl TorrentAddQueryParams {
|
||||
fn into_add_torrent_options(self) -> AddTorrentOptions {
|
||||
pub fn into_add_torrent_options(self) -> AddTorrentOptions {
|
||||
AddTorrentOptions {
|
||||
overwrite: self.overwrite.unwrap_or(false),
|
||||
only_files_regex: self.only_files_regex,
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ impl Serialize for ApiError {
|
|||
error_kind: &'a str,
|
||||
human_readable: String,
|
||||
status: u16,
|
||||
status_text: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
id: Option<usize>,
|
||||
}
|
||||
|
|
@ -85,6 +86,7 @@ impl Serialize for ApiError {
|
|||
},
|
||||
human_readable: format!("{self}"),
|
||||
status: self.status().as_u16(),
|
||||
status_text: self.status().to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
if let ApiErrorKind::TorrentNotFound(id) = &self.kind {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pub mod dht_utils;
|
|||
pub mod file_ops;
|
||||
pub mod http_api;
|
||||
pub mod http_api_client;
|
||||
mod http_api_error;
|
||||
pub mod http_api_error;
|
||||
pub mod peer_connection;
|
||||
pub mod peer_info_reader;
|
||||
pub mod session;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue