Simple mini clone of torrra
This commit is contained in:
@@ -0,0 +1,306 @@
|
||||
// @generated
|
||||
// This file is @generated by prost-build.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct AddRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub magnet: ::prost::alloc::string::String,
|
||||
/// Optional output directory override. Empty means use torad's default.
|
||||
#[prost(string, tag = "2")]
|
||||
pub output_dir: ::prost::alloc::string::String,
|
||||
}
|
||||
impl ::prost::Name for AddRequest {
|
||||
const NAME: &'static str = "AddRequest";
|
||||
const PACKAGE: &'static str = "torrent";
|
||||
fn full_name() -> ::prost::alloc::string::String {
|
||||
"torrent.AddRequest".into()
|
||||
}
|
||||
fn type_url() -> ::prost::alloc::string::String {
|
||||
"/torrent.AddRequest".into()
|
||||
}
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct AddResponse {
|
||||
#[prost(string, tag = "1")]
|
||||
pub id: ::prost::alloc::string::String,
|
||||
}
|
||||
impl ::prost::Name for AddResponse {
|
||||
const NAME: &'static str = "AddResponse";
|
||||
const PACKAGE: &'static str = "torrent";
|
||||
fn full_name() -> ::prost::alloc::string::String {
|
||||
"torrent.AddResponse".into()
|
||||
}
|
||||
fn type_url() -> ::prost::alloc::string::String {
|
||||
"/torrent.AddResponse".into()
|
||||
}
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct StatusRequest {
|
||||
#[prost(string, tag = "1")]
|
||||
pub id: ::prost::alloc::string::String,
|
||||
}
|
||||
impl ::prost::Name for StatusRequest {
|
||||
const NAME: &'static str = "StatusRequest";
|
||||
const PACKAGE: &'static str = "torrent";
|
||||
fn full_name() -> ::prost::alloc::string::String {
|
||||
"torrent.StatusRequest".into()
|
||||
}
|
||||
fn type_url() -> ::prost::alloc::string::String {
|
||||
"/torrent.StatusRequest".into()
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct ListRequest {}
|
||||
impl ::prost::Name for ListRequest {
|
||||
const NAME: &'static str = "ListRequest";
|
||||
const PACKAGE: &'static str = "torrent";
|
||||
fn full_name() -> ::prost::alloc::string::String {
|
||||
"torrent.ListRequest".into()
|
||||
}
|
||||
fn type_url() -> ::prost::alloc::string::String {
|
||||
"/torrent.ListRequest".into()
|
||||
}
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ListResponse {
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub torrents: ::prost::alloc::vec::Vec<TorrentStatus>,
|
||||
}
|
||||
impl ::prost::Name for ListResponse {
|
||||
const NAME: &'static str = "ListResponse";
|
||||
const PACKAGE: &'static str = "torrent";
|
||||
fn full_name() -> ::prost::alloc::string::String {
|
||||
"torrent.ListResponse".into()
|
||||
}
|
||||
fn type_url() -> ::prost::alloc::string::String {
|
||||
"/torrent.ListResponse".into()
|
||||
}
|
||||
}
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
pub struct TorrentStatus {
|
||||
#[prost(string, tag = "1")]
|
||||
pub id: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub info_hash: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "3")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "4")]
|
||||
pub source: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "5")]
|
||||
pub output_path: ::prost::alloc::string::String,
|
||||
#[prost(uint64, tag = "6")]
|
||||
pub total_bytes: u64,
|
||||
#[prost(uint64, tag = "7")]
|
||||
pub downloaded_bytes: u64,
|
||||
#[prost(enumeration = "State", tag = "8")]
|
||||
pub state: i32,
|
||||
#[prost(string, tag = "9")]
|
||||
pub error_message: ::prost::alloc::string::String,
|
||||
}
|
||||
impl ::prost::Name for TorrentStatus {
|
||||
const NAME: &'static str = "TorrentStatus";
|
||||
const PACKAGE: &'static str = "torrent";
|
||||
fn full_name() -> ::prost::alloc::string::String {
|
||||
"torrent.TorrentStatus".into()
|
||||
}
|
||||
fn type_url() -> ::prost::alloc::string::String {
|
||||
"/torrent.TorrentStatus".into()
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
||||
#[repr(i32)]
|
||||
pub enum State {
|
||||
Unspecified = 0,
|
||||
Pending = 1,
|
||||
Downloading = 2,
|
||||
Paused = 3,
|
||||
Finished = 4,
|
||||
Error = 5,
|
||||
}
|
||||
impl State {
|
||||
/// String value of the enum field names used in the ProtoBuf definition.
|
||||
///
|
||||
/// The values are not transformed in any way and thus are considered stable
|
||||
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
||||
pub fn as_str_name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Unspecified => "STATE_UNSPECIFIED",
|
||||
Self::Pending => "PENDING",
|
||||
Self::Downloading => "DOWNLOADING",
|
||||
Self::Paused => "PAUSED",
|
||||
Self::Finished => "FINISHED",
|
||||
Self::Error => "ERROR",
|
||||
}
|
||||
}
|
||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
||||
match value {
|
||||
"STATE_UNSPECIFIED" => Some(Self::Unspecified),
|
||||
"PENDING" => Some(Self::Pending),
|
||||
"DOWNLOADING" => Some(Self::Downloading),
|
||||
"PAUSED" => Some(Self::Paused),
|
||||
"FINISHED" => Some(Self::Finished),
|
||||
"ERROR" => Some(Self::Error),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Encoded file descriptor set for the `torrent` package
|
||||
pub const FILE_DESCRIPTOR_SET: &[u8] = &[
|
||||
0x0a, 0x94, 0x13, 0x0a, 0x0d, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x12, 0x07, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x22, 0x43, 0x0a, 0x0a, 0x41,
|
||||
0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x67,
|
||||
0x6e, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x61, 0x67, 0x6e, 0x65,
|
||||
0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x64, 0x69, 0x72, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x44, 0x69, 0x72,
|
||||
0x22, 0x1d, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22,
|
||||
0x1f, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
|
||||
0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22,
|
||||
0x42, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x32, 0x0a, 0x08, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x16, 0x2e, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x6f, 0x72, 0x72,
|
||||
0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x08, 0x74, 0x6f, 0x72, 0x72, 0x65,
|
||||
0x6e, 0x74, 0x73, 0x22, 0xa0, 0x02, 0x0a, 0x0d, 0x54, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x68, 0x61,
|
||||
0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x66, 0x6f, 0x48, 0x61,
|
||||
0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1f,
|
||||
0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12,
|
||||
0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x06,
|
||||
0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x79, 0x74, 0x65, 0x73,
|
||||
0x12, 0x29, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x5f, 0x62,
|
||||
0x79, 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x64, 0x6f, 0x77, 0x6e,
|
||||
0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x05, 0x73,
|
||||
0x74, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0e, 0x2e, 0x74, 0x6f, 0x72,
|
||||
0x72, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74,
|
||||
0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x61, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12,
|
||||
0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49,
|
||||
0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e,
|
||||
0x47, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x44, 0x4f, 0x57, 0x4e, 0x4c, 0x4f, 0x41, 0x44, 0x49,
|
||||
0x4e, 0x47, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x41, 0x55, 0x53, 0x45, 0x44, 0x10, 0x03,
|
||||
0x12, 0x0c, 0x0a, 0x08, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x48, 0x45, 0x44, 0x10, 0x04, 0x12, 0x09,
|
||||
0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x05, 0x32, 0xab, 0x01, 0x0a, 0x08, 0x54, 0x6f,
|
||||
0x72, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x03, 0x41, 0x64, 0x64, 0x12, 0x13, 0x2e,
|
||||
0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x14, 0x2e, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x64, 0x64,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x12, 0x16, 0x2e, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x74, 0x6f, 0x72,
|
||||
0x72, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74,
|
||||
0x75, 0x73, 0x12, 0x33, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x2e, 0x74, 0x6f, 0x72,
|
||||
0x72, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x15, 0x2e, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4a, 0xe5, 0x0c, 0x0a, 0x06, 0x12, 0x04, 0x00, 0x00,
|
||||
0x34, 0x01, 0x0a, 0x08, 0x0a, 0x01, 0x0c, 0x12, 0x03, 0x00, 0x00, 0x12, 0x0a, 0x08, 0x0a, 0x01,
|
||||
0x02, 0x12, 0x03, 0x02, 0x00, 0x10, 0x0a, 0x0a, 0x0a, 0x02, 0x06, 0x00, 0x12, 0x04, 0x04, 0x00,
|
||||
0x0b, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x06, 0x00, 0x01, 0x12, 0x03, 0x04, 0x08, 0x10, 0x0a, 0x49,
|
||||
0x0a, 0x04, 0x06, 0x00, 0x02, 0x00, 0x12, 0x03, 0x06, 0x02, 0x2c, 0x1a, 0x3c, 0x20, 0x41, 0x64,
|
||||
0x64, 0x20, 0x61, 0x20, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x72, 0x6f, 0x6d,
|
||||
0x20, 0x61, 0x20, 0x6d, 0x61, 0x67, 0x6e, 0x65, 0x74, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x61,
|
||||
0x6e, 0x64, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61,
|
||||
0x64, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x06, 0x00, 0x02,
|
||||
0x00, 0x01, 0x12, 0x03, 0x06, 0x06, 0x09, 0x0a, 0x0c, 0x0a, 0x05, 0x06, 0x00, 0x02, 0x00, 0x02,
|
||||
0x12, 0x03, 0x06, 0x0a, 0x14, 0x0a, 0x0c, 0x0a, 0x05, 0x06, 0x00, 0x02, 0x00, 0x03, 0x12, 0x03,
|
||||
0x06, 0x1f, 0x2a, 0x0a, 0x3a, 0x0a, 0x04, 0x06, 0x00, 0x02, 0x01, 0x12, 0x03, 0x08, 0x02, 0x34,
|
||||
0x1a, 0x2d, 0x20, 0x47, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x75, 0x72, 0x72, 0x65,
|
||||
0x6e, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20, 0x73,
|
||||
0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x2e, 0x0a, 0x0a,
|
||||
0x0c, 0x0a, 0x05, 0x06, 0x00, 0x02, 0x01, 0x01, 0x12, 0x03, 0x08, 0x06, 0x0c, 0x0a, 0x0c, 0x0a,
|
||||
0x05, 0x06, 0x00, 0x02, 0x01, 0x02, 0x12, 0x03, 0x08, 0x0d, 0x1a, 0x0a, 0x0c, 0x0a, 0x05, 0x06,
|
||||
0x00, 0x02, 0x01, 0x03, 0x12, 0x03, 0x08, 0x25, 0x32, 0x0a, 0x35, 0x0a, 0x04, 0x06, 0x00, 0x02,
|
||||
0x02, 0x12, 0x03, 0x0a, 0x02, 0x2f, 0x1a, 0x28, 0x20, 0x4c, 0x69, 0x73, 0x74, 0x20, 0x61, 0x6c,
|
||||
0x6c, 0x20, 0x74, 0x6f, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6b, 0x6e, 0x6f, 0x77, 0x6e,
|
||||
0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x0a,
|
||||
0x0a, 0x0c, 0x0a, 0x05, 0x06, 0x00, 0x02, 0x02, 0x01, 0x12, 0x03, 0x0a, 0x06, 0x0a, 0x0a, 0x0c,
|
||||
0x0a, 0x05, 0x06, 0x00, 0x02, 0x02, 0x02, 0x12, 0x03, 0x0a, 0x0b, 0x16, 0x0a, 0x0c, 0x0a, 0x05,
|
||||
0x06, 0x00, 0x02, 0x02, 0x03, 0x12, 0x03, 0x0a, 0x21, 0x2d, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x00,
|
||||
0x12, 0x04, 0x0d, 0x00, 0x11, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x0d,
|
||||
0x08, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x05, 0x12, 0x03, 0x0e, 0x02, 0x08,
|
||||
0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x00, 0x12, 0x03, 0x0e, 0x02, 0x14, 0x0a, 0x0c, 0x0a,
|
||||
0x05, 0x04, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x0e, 0x09, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04,
|
||||
0x00, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0e, 0x12, 0x13, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02,
|
||||
0x01, 0x05, 0x12, 0x03, 0x10, 0x02, 0x08, 0x0a, 0x53, 0x0a, 0x04, 0x04, 0x00, 0x02, 0x01, 0x12,
|
||||
0x03, 0x10, 0x02, 0x18, 0x1a, 0x46, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x20,
|
||||
0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79,
|
||||
0x20, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x2e, 0x20, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x20, 0x6d, 0x65, 0x61, 0x6e, 0x73, 0x20, 0x75, 0x73, 0x65, 0x20, 0x74, 0x6f, 0x72, 0x61, 0x64,
|
||||
0x27, 0x73, 0x20, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x0a, 0x0a, 0x0c, 0x0a, 0x05,
|
||||
0x04, 0x00, 0x02, 0x01, 0x01, 0x12, 0x03, 0x10, 0x09, 0x13, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00,
|
||||
0x02, 0x01, 0x03, 0x12, 0x03, 0x10, 0x16, 0x17, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x01, 0x12, 0x04,
|
||||
0x13, 0x00, 0x15, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x13, 0x08, 0x13,
|
||||
0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x05, 0x12, 0x03, 0x14, 0x02, 0x08, 0x0a, 0x0b,
|
||||
0x0a, 0x04, 0x04, 0x01, 0x02, 0x00, 0x12, 0x03, 0x14, 0x02, 0x10, 0x0a, 0x0c, 0x0a, 0x05, 0x04,
|
||||
0x01, 0x02, 0x00, 0x01, 0x12, 0x03, 0x14, 0x09, 0x0b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02,
|
||||
0x00, 0x03, 0x12, 0x03, 0x14, 0x0e, 0x0f, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x17,
|
||||
0x00, 0x19, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, 0x03, 0x17, 0x08, 0x15, 0x0a,
|
||||
0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x05, 0x12, 0x03, 0x18, 0x02, 0x08, 0x0a, 0x0b, 0x0a,
|
||||
0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x18, 0x02, 0x10, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02,
|
||||
0x02, 0x00, 0x01, 0x12, 0x03, 0x18, 0x09, 0x0b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00,
|
||||
0x03, 0x12, 0x03, 0x18, 0x0e, 0x0f, 0x0a, 0x09, 0x0a, 0x02, 0x04, 0x03, 0x12, 0x03, 0x1b, 0x00,
|
||||
0x16, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x01, 0x12, 0x03, 0x1b, 0x08, 0x13, 0x0a, 0x0a, 0x0a,
|
||||
0x02, 0x04, 0x04, 0x12, 0x04, 0x1d, 0x00, 0x1f, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x04, 0x01,
|
||||
0x12, 0x03, 0x1d, 0x08, 0x14, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, 0x00, 0x04, 0x12, 0x03,
|
||||
0x1e, 0x02, 0x0a, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x04, 0x02, 0x00, 0x12, 0x03, 0x1e, 0x02, 0x26,
|
||||
0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, 0x00, 0x06, 0x12, 0x03, 0x1e, 0x0b, 0x18, 0x0a, 0x0c,
|
||||
0x0a, 0x05, 0x04, 0x04, 0x02, 0x00, 0x01, 0x12, 0x03, 0x1e, 0x19, 0x21, 0x0a, 0x0c, 0x0a, 0x05,
|
||||
0x04, 0x04, 0x02, 0x00, 0x03, 0x12, 0x03, 0x1e, 0x24, 0x25, 0x0a, 0x0a, 0x0a, 0x02, 0x05, 0x00,
|
||||
0x12, 0x04, 0x21, 0x00, 0x28, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x05, 0x00, 0x01, 0x12, 0x03, 0x21,
|
||||
0x05, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x22, 0x02, 0x13,
|
||||
0x0a, 0x0b, 0x0a, 0x04, 0x05, 0x00, 0x02, 0x00, 0x12, 0x03, 0x22, 0x02, 0x18, 0x0a, 0x0c, 0x0a,
|
||||
0x05, 0x05, 0x00, 0x02, 0x00, 0x02, 0x12, 0x03, 0x22, 0x16, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x05,
|
||||
0x00, 0x02, 0x01, 0x01, 0x12, 0x03, 0x23, 0x02, 0x09, 0x0a, 0x0b, 0x0a, 0x04, 0x05, 0x00, 0x02,
|
||||
0x01, 0x12, 0x03, 0x23, 0x02, 0x0e, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x01, 0x02, 0x12,
|
||||
0x03, 0x23, 0x0c, 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x02, 0x01, 0x12, 0x03, 0x24,
|
||||
0x02, 0x0d, 0x0a, 0x0b, 0x0a, 0x04, 0x05, 0x00, 0x02, 0x02, 0x12, 0x03, 0x24, 0x02, 0x12, 0x0a,
|
||||
0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x02, 0x02, 0x12, 0x03, 0x24, 0x10, 0x11, 0x0a, 0x0c, 0x0a,
|
||||
0x05, 0x05, 0x00, 0x02, 0x03, 0x01, 0x12, 0x03, 0x25, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x05,
|
||||
0x00, 0x02, 0x03, 0x12, 0x03, 0x25, 0x02, 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x03,
|
||||
0x02, 0x12, 0x03, 0x25, 0x0b, 0x0c, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x04, 0x01, 0x12,
|
||||
0x03, 0x26, 0x02, 0x0a, 0x0a, 0x0b, 0x0a, 0x04, 0x05, 0x00, 0x02, 0x04, 0x12, 0x03, 0x26, 0x02,
|
||||
0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x04, 0x02, 0x12, 0x03, 0x26, 0x0d, 0x0e, 0x0a,
|
||||
0x0c, 0x0a, 0x05, 0x05, 0x00, 0x02, 0x05, 0x01, 0x12, 0x03, 0x27, 0x02, 0x07, 0x0a, 0x0b, 0x0a,
|
||||
0x04, 0x05, 0x00, 0x02, 0x05, 0x12, 0x03, 0x27, 0x02, 0x0c, 0x0a, 0x0c, 0x0a, 0x05, 0x05, 0x00,
|
||||
0x02, 0x05, 0x02, 0x12, 0x03, 0x27, 0x0a, 0x0b, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x05, 0x12, 0x04,
|
||||
0x2a, 0x00, 0x34, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x05, 0x01, 0x12, 0x03, 0x2a, 0x08, 0x15,
|
||||
0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x00, 0x05, 0x12, 0x03, 0x2b, 0x02, 0x08, 0x0a, 0x0b,
|
||||
0x0a, 0x04, 0x04, 0x05, 0x02, 0x00, 0x12, 0x03, 0x2b, 0x02, 0x10, 0x0a, 0x0c, 0x0a, 0x05, 0x04,
|
||||
0x05, 0x02, 0x00, 0x01, 0x12, 0x03, 0x2b, 0x09, 0x0b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02,
|
||||
0x00, 0x03, 0x12, 0x03, 0x2b, 0x0e, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x01, 0x05,
|
||||
0x12, 0x03, 0x2c, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x01, 0x12, 0x03, 0x2c,
|
||||
0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x01, 0x01, 0x12, 0x03, 0x2c, 0x09, 0x12,
|
||||
0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x01, 0x03, 0x12, 0x03, 0x2c, 0x15, 0x16, 0x0a, 0x0c,
|
||||
0x0a, 0x05, 0x04, 0x05, 0x02, 0x02, 0x05, 0x12, 0x03, 0x2d, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04,
|
||||
0x04, 0x05, 0x02, 0x02, 0x12, 0x03, 0x2d, 0x02, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02,
|
||||
0x02, 0x01, 0x12, 0x03, 0x2d, 0x09, 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x02, 0x03,
|
||||
0x12, 0x03, 0x2d, 0x10, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x03, 0x05, 0x12, 0x03,
|
||||
0x2e, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x03, 0x12, 0x03, 0x2e, 0x02, 0x14,
|
||||
0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x03, 0x01, 0x12, 0x03, 0x2e, 0x09, 0x0f, 0x0a, 0x0c,
|
||||
0x0a, 0x05, 0x04, 0x05, 0x02, 0x03, 0x03, 0x12, 0x03, 0x2e, 0x12, 0x13, 0x0a, 0x0c, 0x0a, 0x05,
|
||||
0x04, 0x05, 0x02, 0x04, 0x05, 0x12, 0x03, 0x2f, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05,
|
||||
0x02, 0x04, 0x12, 0x03, 0x2f, 0x02, 0x19, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x04, 0x01,
|
||||
0x12, 0x03, 0x2f, 0x09, 0x14, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x04, 0x03, 0x12, 0x03,
|
||||
0x2f, 0x17, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x05, 0x05, 0x12, 0x03, 0x30, 0x02,
|
||||
0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x05, 0x12, 0x03, 0x30, 0x02, 0x19, 0x0a, 0x0c,
|
||||
0x0a, 0x05, 0x04, 0x05, 0x02, 0x05, 0x01, 0x12, 0x03, 0x30, 0x09, 0x14, 0x0a, 0x0c, 0x0a, 0x05,
|
||||
0x04, 0x05, 0x02, 0x05, 0x03, 0x12, 0x03, 0x30, 0x17, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05,
|
||||
0x02, 0x06, 0x05, 0x12, 0x03, 0x31, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x06,
|
||||
0x12, 0x03, 0x31, 0x02, 0x1e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x06, 0x01, 0x12, 0x03,
|
||||
0x31, 0x09, 0x19, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x06, 0x03, 0x12, 0x03, 0x31, 0x1c,
|
||||
0x1d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x07, 0x06, 0x12, 0x03, 0x32, 0x02, 0x07, 0x0a,
|
||||
0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x07, 0x12, 0x03, 0x32, 0x02, 0x12, 0x0a, 0x0c, 0x0a, 0x05,
|
||||
0x04, 0x05, 0x02, 0x07, 0x01, 0x12, 0x03, 0x32, 0x08, 0x0d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05,
|
||||
0x02, 0x07, 0x03, 0x12, 0x03, 0x32, 0x10, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x08,
|
||||
0x05, 0x12, 0x03, 0x33, 0x02, 0x08, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x08, 0x12, 0x03,
|
||||
0x33, 0x02, 0x1b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x08, 0x01, 0x12, 0x03, 0x33, 0x09,
|
||||
0x16, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x08, 0x03, 0x12, 0x03, 0x33, 0x19, 0x1a, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
];
|
||||
include!("torrent.serde.rs");
|
||||
include!("torrent.tonic.rs");
|
||||
// @@protoc_insertion_point(module)
|
||||
@@ -0,0 +1,795 @@
|
||||
// @generated
|
||||
impl serde::Serialize for AddRequest {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let mut len = 0;
|
||||
if !self.magnet.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
if !self.output_dir.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
let mut struct_ser = serializer.serialize_struct("torrent.AddRequest", len)?;
|
||||
if !self.magnet.is_empty() {
|
||||
struct_ser.serialize_field("magnet", &self.magnet)?;
|
||||
}
|
||||
if !self.output_dir.is_empty() {
|
||||
struct_ser.serialize_field("outputDir", &self.output_dir)?;
|
||||
}
|
||||
struct_ser.end()
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for AddRequest {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &["magnet", "output_dir", "outputDir"];
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum GeneratedField {
|
||||
Magnet,
|
||||
OutputDir,
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for GeneratedField {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = GeneratedField;
|
||||
|
||||
fn expecting(
|
||||
&self,
|
||||
formatter: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
match value {
|
||||
"magnet" => Ok(GeneratedField::Magnet),
|
||||
"outputDir" | "output_dir" => Ok(GeneratedField::OutputDir),
|
||||
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
|
||||
}
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_identifier(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
struct GeneratedVisitor;
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = AddRequest;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("struct torrent.AddRequest")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<AddRequest, V::Error>
|
||||
where
|
||||
V: serde::de::MapAccess<'de>,
|
||||
{
|
||||
let mut magnet__ = None;
|
||||
let mut output_dir__ = None;
|
||||
while let Some(k) = map_.next_key()? {
|
||||
match k {
|
||||
GeneratedField::Magnet => {
|
||||
if magnet__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("magnet"));
|
||||
}
|
||||
magnet__ = Some(map_.next_value()?);
|
||||
}
|
||||
GeneratedField::OutputDir => {
|
||||
if output_dir__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("outputDir"));
|
||||
}
|
||||
output_dir__ = Some(map_.next_value()?);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(AddRequest {
|
||||
magnet: magnet__.unwrap_or_default(),
|
||||
output_dir: output_dir__.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_struct("torrent.AddRequest", FIELDS, GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
impl serde::Serialize for AddResponse {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let mut len = 0;
|
||||
if !self.id.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
let mut struct_ser = serializer.serialize_struct("torrent.AddResponse", len)?;
|
||||
if !self.id.is_empty() {
|
||||
struct_ser.serialize_field("id", &self.id)?;
|
||||
}
|
||||
struct_ser.end()
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for AddResponse {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &["id"];
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum GeneratedField {
|
||||
Id,
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for GeneratedField {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = GeneratedField;
|
||||
|
||||
fn expecting(
|
||||
&self,
|
||||
formatter: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
match value {
|
||||
"id" => Ok(GeneratedField::Id),
|
||||
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
|
||||
}
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_identifier(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
struct GeneratedVisitor;
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = AddResponse;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("struct torrent.AddResponse")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<AddResponse, V::Error>
|
||||
where
|
||||
V: serde::de::MapAccess<'de>,
|
||||
{
|
||||
let mut id__ = None;
|
||||
while let Some(k) = map_.next_key()? {
|
||||
match k {
|
||||
GeneratedField::Id => {
|
||||
if id__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("id"));
|
||||
}
|
||||
id__ = Some(map_.next_value()?);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(AddResponse {
|
||||
id: id__.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_struct("torrent.AddResponse", FIELDS, GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
impl serde::Serialize for ListRequest {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let len = 0;
|
||||
let struct_ser = serializer.serialize_struct("torrent.ListRequest", len)?;
|
||||
struct_ser.end()
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for ListRequest {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &[];
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum GeneratedField {}
|
||||
impl<'de> serde::Deserialize<'de> for GeneratedField {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = GeneratedField;
|
||||
|
||||
fn expecting(
|
||||
&self,
|
||||
formatter: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
Err(serde::de::Error::unknown_field(value, FIELDS))
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_identifier(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
struct GeneratedVisitor;
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = ListRequest;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("struct torrent.ListRequest")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<ListRequest, V::Error>
|
||||
where
|
||||
V: serde::de::MapAccess<'de>,
|
||||
{
|
||||
while map_.next_key::<GeneratedField>()?.is_some() {
|
||||
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
|
||||
}
|
||||
Ok(ListRequest {})
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_struct("torrent.ListRequest", FIELDS, GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
impl serde::Serialize for ListResponse {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let mut len = 0;
|
||||
if !self.torrents.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
let mut struct_ser = serializer.serialize_struct("torrent.ListResponse", len)?;
|
||||
if !self.torrents.is_empty() {
|
||||
struct_ser.serialize_field("torrents", &self.torrents)?;
|
||||
}
|
||||
struct_ser.end()
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for ListResponse {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &["torrents"];
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum GeneratedField {
|
||||
Torrents,
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for GeneratedField {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = GeneratedField;
|
||||
|
||||
fn expecting(
|
||||
&self,
|
||||
formatter: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
match value {
|
||||
"torrents" => Ok(GeneratedField::Torrents),
|
||||
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
|
||||
}
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_identifier(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
struct GeneratedVisitor;
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = ListResponse;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("struct torrent.ListResponse")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<ListResponse, V::Error>
|
||||
where
|
||||
V: serde::de::MapAccess<'de>,
|
||||
{
|
||||
let mut torrents__ = None;
|
||||
while let Some(k) = map_.next_key()? {
|
||||
match k {
|
||||
GeneratedField::Torrents => {
|
||||
if torrents__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("torrents"));
|
||||
}
|
||||
torrents__ = Some(map_.next_value()?);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(ListResponse {
|
||||
torrents: torrents__.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_struct("torrent.ListResponse", FIELDS, GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
impl serde::Serialize for State {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
let variant = match self {
|
||||
Self::Unspecified => "STATE_UNSPECIFIED",
|
||||
Self::Pending => "PENDING",
|
||||
Self::Downloading => "DOWNLOADING",
|
||||
Self::Paused => "PAUSED",
|
||||
Self::Finished => "FINISHED",
|
||||
Self::Error => "ERROR",
|
||||
};
|
||||
serializer.serialize_str(variant)
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for State {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &[
|
||||
"STATE_UNSPECIFIED",
|
||||
"PENDING",
|
||||
"DOWNLOADING",
|
||||
"PAUSED",
|
||||
"FINISHED",
|
||||
"ERROR",
|
||||
];
|
||||
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = State;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
fn visit_i64<E>(self, v: i64) -> std::result::Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
i32::try_from(v)
|
||||
.ok()
|
||||
.and_then(|x| x.try_into().ok())
|
||||
.ok_or_else(|| {
|
||||
serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self)
|
||||
})
|
||||
}
|
||||
|
||||
fn visit_u64<E>(self, v: u64) -> std::result::Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
i32::try_from(v)
|
||||
.ok()
|
||||
.and_then(|x| x.try_into().ok())
|
||||
.ok_or_else(|| {
|
||||
serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self)
|
||||
})
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
match value {
|
||||
"STATE_UNSPECIFIED" => Ok(State::Unspecified),
|
||||
"PENDING" => Ok(State::Pending),
|
||||
"DOWNLOADING" => Ok(State::Downloading),
|
||||
"PAUSED" => Ok(State::Paused),
|
||||
"FINISHED" => Ok(State::Finished),
|
||||
"ERROR" => Ok(State::Error),
|
||||
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
|
||||
}
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_any(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
impl serde::Serialize for StatusRequest {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let mut len = 0;
|
||||
if !self.id.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
let mut struct_ser = serializer.serialize_struct("torrent.StatusRequest", len)?;
|
||||
if !self.id.is_empty() {
|
||||
struct_ser.serialize_field("id", &self.id)?;
|
||||
}
|
||||
struct_ser.end()
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for StatusRequest {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &["id"];
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum GeneratedField {
|
||||
Id,
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for GeneratedField {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = GeneratedField;
|
||||
|
||||
fn expecting(
|
||||
&self,
|
||||
formatter: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
match value {
|
||||
"id" => Ok(GeneratedField::Id),
|
||||
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
|
||||
}
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_identifier(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
struct GeneratedVisitor;
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = StatusRequest;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("struct torrent.StatusRequest")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<StatusRequest, V::Error>
|
||||
where
|
||||
V: serde::de::MapAccess<'de>,
|
||||
{
|
||||
let mut id__ = None;
|
||||
while let Some(k) = map_.next_key()? {
|
||||
match k {
|
||||
GeneratedField::Id => {
|
||||
if id__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("id"));
|
||||
}
|
||||
id__ = Some(map_.next_value()?);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(StatusRequest {
|
||||
id: id__.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_struct("torrent.StatusRequest", FIELDS, GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
impl serde::Serialize for TorrentStatus {
|
||||
#[allow(deprecated)]
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
use serde::ser::SerializeStruct;
|
||||
let mut len = 0;
|
||||
if !self.id.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
if !self.info_hash.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
if !self.name.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
if !self.source.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
if !self.output_path.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
if self.total_bytes != 0 {
|
||||
len += 1;
|
||||
}
|
||||
if self.downloaded_bytes != 0 {
|
||||
len += 1;
|
||||
}
|
||||
if self.state != 0 {
|
||||
len += 1;
|
||||
}
|
||||
if !self.error_message.is_empty() {
|
||||
len += 1;
|
||||
}
|
||||
let mut struct_ser = serializer.serialize_struct("torrent.TorrentStatus", len)?;
|
||||
if !self.id.is_empty() {
|
||||
struct_ser.serialize_field("id", &self.id)?;
|
||||
}
|
||||
if !self.info_hash.is_empty() {
|
||||
struct_ser.serialize_field("infoHash", &self.info_hash)?;
|
||||
}
|
||||
if !self.name.is_empty() {
|
||||
struct_ser.serialize_field("name", &self.name)?;
|
||||
}
|
||||
if !self.source.is_empty() {
|
||||
struct_ser.serialize_field("source", &self.source)?;
|
||||
}
|
||||
if !self.output_path.is_empty() {
|
||||
struct_ser.serialize_field("outputPath", &self.output_path)?;
|
||||
}
|
||||
if self.total_bytes != 0 {
|
||||
#[allow(clippy::needless_borrow)]
|
||||
#[allow(clippy::needless_borrows_for_generic_args)]
|
||||
struct_ser.serialize_field(
|
||||
"totalBytes",
|
||||
ToString::to_string(&self.total_bytes).as_str(),
|
||||
)?;
|
||||
}
|
||||
if self.downloaded_bytes != 0 {
|
||||
#[allow(clippy::needless_borrow)]
|
||||
#[allow(clippy::needless_borrows_for_generic_args)]
|
||||
struct_ser.serialize_field(
|
||||
"downloadedBytes",
|
||||
ToString::to_string(&self.downloaded_bytes).as_str(),
|
||||
)?;
|
||||
}
|
||||
if self.state != 0 {
|
||||
let v = State::try_from(self.state).map_err(|_| {
|
||||
serde::ser::Error::custom(format!("Invalid variant {}", self.state))
|
||||
})?;
|
||||
struct_ser.serialize_field("state", &v)?;
|
||||
}
|
||||
if !self.error_message.is_empty() {
|
||||
struct_ser.serialize_field("errorMessage", &self.error_message)?;
|
||||
}
|
||||
struct_ser.end()
|
||||
}
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for TorrentStatus {
|
||||
#[allow(deprecated)]
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
const FIELDS: &[&str] = &[
|
||||
"id",
|
||||
"info_hash",
|
||||
"infoHash",
|
||||
"name",
|
||||
"source",
|
||||
"output_path",
|
||||
"outputPath",
|
||||
"total_bytes",
|
||||
"totalBytes",
|
||||
"downloaded_bytes",
|
||||
"downloadedBytes",
|
||||
"state",
|
||||
"error_message",
|
||||
"errorMessage",
|
||||
];
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
enum GeneratedField {
|
||||
Id,
|
||||
InfoHash,
|
||||
Name,
|
||||
Source,
|
||||
OutputPath,
|
||||
TotalBytes,
|
||||
DownloadedBytes,
|
||||
State,
|
||||
ErrorMessage,
|
||||
}
|
||||
impl<'de> serde::Deserialize<'de> for GeneratedField {
|
||||
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
struct GeneratedVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = GeneratedField;
|
||||
|
||||
fn expecting(
|
||||
&self,
|
||||
formatter: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
write!(formatter, "expected one of: {:?}", &FIELDS)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
match value {
|
||||
"id" => Ok(GeneratedField::Id),
|
||||
"infoHash" | "info_hash" => Ok(GeneratedField::InfoHash),
|
||||
"name" => Ok(GeneratedField::Name),
|
||||
"source" => Ok(GeneratedField::Source),
|
||||
"outputPath" | "output_path" => Ok(GeneratedField::OutputPath),
|
||||
"totalBytes" | "total_bytes" => Ok(GeneratedField::TotalBytes),
|
||||
"downloadedBytes" | "downloaded_bytes" => {
|
||||
Ok(GeneratedField::DownloadedBytes)
|
||||
}
|
||||
"state" => Ok(GeneratedField::State),
|
||||
"errorMessage" | "error_message" => Ok(GeneratedField::ErrorMessage),
|
||||
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
|
||||
}
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_identifier(GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
struct GeneratedVisitor;
|
||||
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
|
||||
type Value = TorrentStatus;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
formatter.write_str("struct torrent.TorrentStatus")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut map_: V) -> std::result::Result<TorrentStatus, V::Error>
|
||||
where
|
||||
V: serde::de::MapAccess<'de>,
|
||||
{
|
||||
let mut id__ = None;
|
||||
let mut info_hash__ = None;
|
||||
let mut name__ = None;
|
||||
let mut source__ = None;
|
||||
let mut output_path__ = None;
|
||||
let mut total_bytes__ = None;
|
||||
let mut downloaded_bytes__ = None;
|
||||
let mut state__ = None;
|
||||
let mut error_message__ = None;
|
||||
while let Some(k) = map_.next_key()? {
|
||||
match k {
|
||||
GeneratedField::Id => {
|
||||
if id__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("id"));
|
||||
}
|
||||
id__ = Some(map_.next_value()?);
|
||||
}
|
||||
GeneratedField::InfoHash => {
|
||||
if info_hash__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("infoHash"));
|
||||
}
|
||||
info_hash__ = Some(map_.next_value()?);
|
||||
}
|
||||
GeneratedField::Name => {
|
||||
if name__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("name"));
|
||||
}
|
||||
name__ = Some(map_.next_value()?);
|
||||
}
|
||||
GeneratedField::Source => {
|
||||
if source__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("source"));
|
||||
}
|
||||
source__ = Some(map_.next_value()?);
|
||||
}
|
||||
GeneratedField::OutputPath => {
|
||||
if output_path__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("outputPath"));
|
||||
}
|
||||
output_path__ = Some(map_.next_value()?);
|
||||
}
|
||||
GeneratedField::TotalBytes => {
|
||||
if total_bytes__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("totalBytes"));
|
||||
}
|
||||
total_bytes__ = Some(
|
||||
map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?
|
||||
.0,
|
||||
);
|
||||
}
|
||||
GeneratedField::DownloadedBytes => {
|
||||
if downloaded_bytes__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("downloadedBytes"));
|
||||
}
|
||||
downloaded_bytes__ = Some(
|
||||
map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?
|
||||
.0,
|
||||
);
|
||||
}
|
||||
GeneratedField::State => {
|
||||
if state__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("state"));
|
||||
}
|
||||
state__ = Some(map_.next_value::<State>()? as i32);
|
||||
}
|
||||
GeneratedField::ErrorMessage => {
|
||||
if error_message__.is_some() {
|
||||
return Err(serde::de::Error::duplicate_field("errorMessage"));
|
||||
}
|
||||
error_message__ = Some(map_.next_value()?);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(TorrentStatus {
|
||||
id: id__.unwrap_or_default(),
|
||||
info_hash: info_hash__.unwrap_or_default(),
|
||||
name: name__.unwrap_or_default(),
|
||||
source: source__.unwrap_or_default(),
|
||||
output_path: output_path__.unwrap_or_default(),
|
||||
total_bytes: total_bytes__.unwrap_or_default(),
|
||||
downloaded_bytes: downloaded_bytes__.unwrap_or_default(),
|
||||
state: state__.unwrap_or_default(),
|
||||
error_message: error_message__.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
deserializer.deserialize_struct("torrent.TorrentStatus", FIELDS, GeneratedVisitor)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
// @generated
|
||||
/// Generated client implementations.
|
||||
pub mod torrents_client {
|
||||
#![allow(
|
||||
unused_variables,
|
||||
dead_code,
|
||||
missing_docs,
|
||||
clippy::wildcard_imports,
|
||||
clippy::let_unit_value
|
||||
)]
|
||||
use tonic::codegen::http::Uri;
|
||||
use tonic::codegen::*;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TorrentsClient<T> {
|
||||
inner: tonic::client::Grpc<T>,
|
||||
}
|
||||
impl TorrentsClient<tonic::transport::Channel> {
|
||||
/// Attempt to create a new client by connecting to a given endpoint.
|
||||
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
|
||||
where
|
||||
D: TryInto<tonic::transport::Endpoint>,
|
||||
D::Error: Into<StdError>,
|
||||
{
|
||||
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
|
||||
Ok(Self::new(conn))
|
||||
}
|
||||
}
|
||||
impl<T> TorrentsClient<T>
|
||||
where
|
||||
T: tonic::client::GrpcService<tonic::body::Body>,
|
||||
T::Error: Into<StdError>,
|
||||
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
||||
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
|
||||
{
|
||||
pub fn new(inner: T) -> Self {
|
||||
let inner = tonic::client::Grpc::new(inner);
|
||||
Self { inner }
|
||||
}
|
||||
pub fn with_origin(inner: T, origin: Uri) -> Self {
|
||||
let inner = tonic::client::Grpc::with_origin(inner, origin);
|
||||
Self { inner }
|
||||
}
|
||||
pub fn with_interceptor<F>(
|
||||
inner: T,
|
||||
interceptor: F,
|
||||
) -> TorrentsClient<InterceptedService<T, F>>
|
||||
where
|
||||
F: tonic::service::Interceptor,
|
||||
T::ResponseBody: Default,
|
||||
T: tonic::codegen::Service<
|
||||
http::Request<tonic::body::Body>,
|
||||
Response = http::Response<
|
||||
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
|
||||
>,
|
||||
>,
|
||||
<T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
|
||||
Into<StdError> + std::marker::Send + std::marker::Sync,
|
||||
{
|
||||
TorrentsClient::new(InterceptedService::new(inner, interceptor))
|
||||
}
|
||||
/// Compress requests with the given encoding.
|
||||
///
|
||||
/// This requires the server to support it otherwise it might respond with an
|
||||
/// error.
|
||||
#[must_use]
|
||||
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.inner = self.inner.send_compressed(encoding);
|
||||
self
|
||||
}
|
||||
/// Enable decompressing responses.
|
||||
#[must_use]
|
||||
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.inner = self.inner.accept_compressed(encoding);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of a decoded message.
|
||||
///
|
||||
/// Default: `4MB`
|
||||
#[must_use]
|
||||
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.inner = self.inner.max_decoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of an encoded message.
|
||||
///
|
||||
/// Default: `usize::MAX`
|
||||
#[must_use]
|
||||
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.inner = self.inner.max_encoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
pub async fn add(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::AddRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::AddResponse>, tonic::Status> {
|
||||
self.inner.ready().await.map_err(|e| {
|
||||
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
|
||||
})?;
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let path = http::uri::PathAndQuery::from_static("/torrent.Torrents/Add");
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(GrpcMethod::new("torrent.Torrents", "Add"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn status(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::StatusRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::TorrentStatus>, tonic::Status> {
|
||||
self.inner.ready().await.map_err(|e| {
|
||||
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
|
||||
})?;
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let path = http::uri::PathAndQuery::from_static("/torrent.Torrents/Status");
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(GrpcMethod::new("torrent.Torrents", "Status"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
pub async fn list(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::ListRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::ListResponse>, tonic::Status> {
|
||||
self.inner.ready().await.map_err(|e| {
|
||||
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
|
||||
})?;
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let path = http::uri::PathAndQuery::from_static("/torrent.Torrents/List");
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(GrpcMethod::new("torrent.Torrents", "List"));
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Generated server implementations.
|
||||
pub mod torrents_server {
|
||||
#![allow(
|
||||
unused_variables,
|
||||
dead_code,
|
||||
missing_docs,
|
||||
clippy::wildcard_imports,
|
||||
clippy::let_unit_value
|
||||
)]
|
||||
use tonic::codegen::*;
|
||||
/// Generated trait containing gRPC methods that should be implemented for use with TorrentsServer.
|
||||
#[async_trait]
|
||||
pub trait Torrents: std::marker::Send + std::marker::Sync + 'static {
|
||||
async fn add(
|
||||
&self,
|
||||
request: tonic::Request<super::AddRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::AddResponse>, tonic::Status>;
|
||||
async fn status(
|
||||
&self,
|
||||
request: tonic::Request<super::StatusRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::TorrentStatus>, tonic::Status>;
|
||||
async fn list(
|
||||
&self,
|
||||
request: tonic::Request<super::ListRequest>,
|
||||
) -> std::result::Result<tonic::Response<super::ListResponse>, tonic::Status>;
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct TorrentsServer<T> {
|
||||
inner: Arc<T>,
|
||||
accept_compression_encodings: EnabledCompressionEncodings,
|
||||
send_compression_encodings: EnabledCompressionEncodings,
|
||||
max_decoding_message_size: Option<usize>,
|
||||
max_encoding_message_size: Option<usize>,
|
||||
}
|
||||
impl<T> TorrentsServer<T> {
|
||||
pub fn new(inner: T) -> Self {
|
||||
Self::from_arc(Arc::new(inner))
|
||||
}
|
||||
pub fn from_arc(inner: Arc<T>) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
accept_compression_encodings: Default::default(),
|
||||
send_compression_encodings: Default::default(),
|
||||
max_decoding_message_size: None,
|
||||
max_encoding_message_size: None,
|
||||
}
|
||||
}
|
||||
pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
|
||||
where
|
||||
F: tonic::service::Interceptor,
|
||||
{
|
||||
InterceptedService::new(Self::new(inner), interceptor)
|
||||
}
|
||||
/// Enable decompressing requests with the given encoding.
|
||||
#[must_use]
|
||||
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.accept_compression_encodings.enable(encoding);
|
||||
self
|
||||
}
|
||||
/// Compress responses with the given encoding, if the client supports it.
|
||||
#[must_use]
|
||||
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.send_compression_encodings.enable(encoding);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of a decoded message.
|
||||
///
|
||||
/// Default: `4MB`
|
||||
#[must_use]
|
||||
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.max_decoding_message_size = Some(limit);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of an encoded message.
|
||||
///
|
||||
/// Default: `usize::MAX`
|
||||
#[must_use]
|
||||
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.max_encoding_message_size = Some(limit);
|
||||
self
|
||||
}
|
||||
}
|
||||
impl<T, B> tonic::codegen::Service<http::Request<B>> for TorrentsServer<T>
|
||||
where
|
||||
T: Torrents,
|
||||
B: Body + std::marker::Send + 'static,
|
||||
B::Error: Into<StdError> + std::marker::Send + 'static,
|
||||
{
|
||||
type Response = http::Response<tonic::body::Body>;
|
||||
type Error = std::convert::Infallible;
|
||||
type Future = BoxFuture<Self::Response, Self::Error>;
|
||||
fn poll_ready(
|
||||
&mut self,
|
||||
_cx: &mut Context<'_>,
|
||||
) -> Poll<std::result::Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
fn call(&mut self, req: http::Request<B>) -> Self::Future {
|
||||
match req.uri().path() {
|
||||
"/torrent.Torrents/Add" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct AddSvc<T: Torrents>(pub Arc<T>);
|
||||
impl<T: Torrents> tonic::server::UnaryService<super::AddRequest> for AddSvc<T> {
|
||||
type Response = super::AddResponse;
|
||||
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::AddRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move { <T as Torrents>::add(&inner, request).await };
|
||||
Box::pin(fut)
|
||||
}
|
||||
}
|
||||
let accept_compression_encodings = self.accept_compression_encodings;
|
||||
let send_compression_encodings = self.send_compression_encodings;
|
||||
let max_decoding_message_size = self.max_decoding_message_size;
|
||||
let max_encoding_message_size = self.max_encoding_message_size;
|
||||
let inner = self.inner.clone();
|
||||
let fut = async move {
|
||||
let method = AddSvc(inner);
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let mut grpc = tonic::server::Grpc::new(codec)
|
||||
.apply_compression_config(
|
||||
accept_compression_encodings,
|
||||
send_compression_encodings,
|
||||
)
|
||||
.apply_max_message_size_config(
|
||||
max_decoding_message_size,
|
||||
max_encoding_message_size,
|
||||
);
|
||||
let res = grpc.unary(method, req).await;
|
||||
Ok(res)
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
"/torrent.Torrents/Status" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct StatusSvc<T: Torrents>(pub Arc<T>);
|
||||
impl<T: Torrents> tonic::server::UnaryService<super::StatusRequest> for StatusSvc<T> {
|
||||
type Response = super::TorrentStatus;
|
||||
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::StatusRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move { <T as Torrents>::status(&inner, request).await };
|
||||
Box::pin(fut)
|
||||
}
|
||||
}
|
||||
let accept_compression_encodings = self.accept_compression_encodings;
|
||||
let send_compression_encodings = self.send_compression_encodings;
|
||||
let max_decoding_message_size = self.max_decoding_message_size;
|
||||
let max_encoding_message_size = self.max_encoding_message_size;
|
||||
let inner = self.inner.clone();
|
||||
let fut = async move {
|
||||
let method = StatusSvc(inner);
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let mut grpc = tonic::server::Grpc::new(codec)
|
||||
.apply_compression_config(
|
||||
accept_compression_encodings,
|
||||
send_compression_encodings,
|
||||
)
|
||||
.apply_max_message_size_config(
|
||||
max_decoding_message_size,
|
||||
max_encoding_message_size,
|
||||
);
|
||||
let res = grpc.unary(method, req).await;
|
||||
Ok(res)
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
"/torrent.Torrents/List" => {
|
||||
#[allow(non_camel_case_types)]
|
||||
struct ListSvc<T: Torrents>(pub Arc<T>);
|
||||
impl<T: Torrents> tonic::server::UnaryService<super::ListRequest> for ListSvc<T> {
|
||||
type Response = super::ListResponse;
|
||||
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
|
||||
fn call(
|
||||
&mut self,
|
||||
request: tonic::Request<super::ListRequest>,
|
||||
) -> Self::Future {
|
||||
let inner = Arc::clone(&self.0);
|
||||
let fut = async move { <T as Torrents>::list(&inner, request).await };
|
||||
Box::pin(fut)
|
||||
}
|
||||
}
|
||||
let accept_compression_encodings = self.accept_compression_encodings;
|
||||
let send_compression_encodings = self.send_compression_encodings;
|
||||
let max_decoding_message_size = self.max_decoding_message_size;
|
||||
let max_encoding_message_size = self.max_encoding_message_size;
|
||||
let inner = self.inner.clone();
|
||||
let fut = async move {
|
||||
let method = ListSvc(inner);
|
||||
let codec = tonic_prost::ProstCodec::default();
|
||||
let mut grpc = tonic::server::Grpc::new(codec)
|
||||
.apply_compression_config(
|
||||
accept_compression_encodings,
|
||||
send_compression_encodings,
|
||||
)
|
||||
.apply_max_message_size_config(
|
||||
max_decoding_message_size,
|
||||
max_encoding_message_size,
|
||||
);
|
||||
let res = grpc.unary(method, req).await;
|
||||
Ok(res)
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
_ => Box::pin(async move {
|
||||
let mut response = http::Response::new(tonic::body::Body::default());
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
tonic::Status::GRPC_STATUS,
|
||||
(tonic::Code::Unimplemented as i32).into(),
|
||||
);
|
||||
headers.insert(
|
||||
http::header::CONTENT_TYPE,
|
||||
tonic::metadata::GRPC_CONTENT_TYPE,
|
||||
);
|
||||
Ok(response)
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<T> Clone for TorrentsServer<T> {
|
||||
fn clone(&self) -> Self {
|
||||
let inner = self.inner.clone();
|
||||
Self {
|
||||
inner,
|
||||
accept_compression_encodings: self.accept_compression_encodings,
|
||||
send_compression_encodings: self.send_compression_encodings,
|
||||
max_decoding_message_size: self.max_decoding_message_size,
|
||||
max_encoding_message_size: self.max_encoding_message_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Generated gRPC service name
|
||||
pub const SERVICE_NAME: &str = "torrent.Torrents";
|
||||
impl<T> tonic::server::NamedService for TorrentsServer<T> {
|
||||
const NAME: &'static str = SERVICE_NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
pub mod torrent {
|
||||
include!("generated/torrent/torrent.rs");
|
||||
}
|
||||
|
||||
pub use torrent::{
|
||||
AddRequest, AddResponse, ListRequest, ListResponse, State, StatusRequest, TorrentStatus,
|
||||
torrents_client::TorrentsClient,
|
||||
torrents_server::{Torrents, TorrentsServer},
|
||||
};
|
||||
Reference in New Issue
Block a user