Improving typescript types
This commit is contained in:
parent
e9d4dc4e3a
commit
99db087cf1
7 changed files with 190 additions and 33 deletions
|
|
@ -12,6 +12,8 @@ use peer_binary_protocol::{
|
|||
serialize_piece_preamble, Handshake, Message, MessageBorrowed, MessageDeserializeError,
|
||||
MessageOwned, PIECE_MESSAGE_DEFAULT_LEN,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::serde_as;
|
||||
use tokio::time::timeout;
|
||||
use tracing::trace;
|
||||
|
||||
|
|
@ -38,10 +40,16 @@ pub enum WriterRequest {
|
|||
Disconnect,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Copy, Clone)]
|
||||
#[serde_as]
|
||||
#[derive(Default, Debug, Copy, Clone, Serialize, Deserialize)]
|
||||
pub struct PeerConnectionOptions {
|
||||
#[serde_as(as = "Option<serde_with::DurationSeconds>")]
|
||||
pub connect_timeout: Option<Duration>,
|
||||
|
||||
#[serde_as(as = "Option<serde_with::DurationSeconds>")]
|
||||
pub read_write_timeout: Option<Duration>,
|
||||
|
||||
#[serde_as(as = "Option<serde_with::DurationSeconds>")]
|
||||
pub keep_alive_interval: Option<Duration>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use librqbit_core::{
|
|||
use parking_lot::RwLock;
|
||||
use reqwest::Url;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_with::serde_as;
|
||||
use tracing::{debug, error, error_span, info, warn};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -181,7 +182,8 @@ fn compute_only_files<ByteBuf: AsRef<[u8]>>(
|
|||
Ok(only_files)
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
#[serde_as]
|
||||
#[derive(Default, Clone, Serialize, Deserialize)]
|
||||
pub struct AddTorrentOptions {
|
||||
pub paused: bool,
|
||||
pub only_files_regex: Option<String>,
|
||||
|
|
@ -191,9 +193,11 @@ pub struct AddTorrentOptions {
|
|||
pub output_folder: Option<String>,
|
||||
pub sub_folder: Option<String>,
|
||||
pub peer_opts: Option<PeerConnectionOptions>,
|
||||
#[serde_as(as = "Option<serde_with::DurationSeconds>")]
|
||||
pub force_tracker_interval: Option<Duration>,
|
||||
pub initial_peers: Option<Vec<SocketAddr>>,
|
||||
// This is used to restore the session.
|
||||
#[serde(skip)]
|
||||
pub preferred_id: Option<usize>,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue