Skip to content

Commit

Permalink
chore: rustfmt & clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Aug 14, 2024
1 parent a711963 commit bc5fda3
Show file tree
Hide file tree
Showing 30 changed files with 390 additions and 131 deletions.
1 change: 0 additions & 1 deletion stremio-core-protobuf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use prost_build::Config;

pub const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
fn main() {

let proto_dir = PathBuf::from(CARGO_MANIFEST_DIR).join("proto");

let proto_paths = glob(format!("{}/**/*.proto", proto_dir.display()).as_str())
Expand Down
1 change: 0 additions & 1 deletion stremio-core-protobuf/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ pub trait FromProtobuf<T> {
#[allow(clippy::wrong_self_convention)]
fn from_protobuf(&self) -> T;
}

6 changes: 2 additions & 4 deletions stremio-core-protobuf/src/bridge/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ impl FromProtobuf<Action> for runtime::Action {
// }
// }



// impl<E, M> FromProtobuf<RuntimeAction<E, M>> for runtime::RuntimeAction
impl<E, M, F> FromProtobuf<RuntimeAction<E, M>> for runtime::RuntimeAction
where
Expand All @@ -273,8 +271,8 @@ where
field: self
.field
.and_then(|value| Field::try_from(value).ok().map(Into::into)),
// .from_protobuf(),
// .from_protobuf(),
action: self.action.from_protobuf(),
}
}
}
}
5 changes: 4 additions & 1 deletion stremio-core-protobuf/src/bridge/auth_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ impl FromProtobuf<AuthRequest> for types::AuthRequest {
}

impl ToProtobuf<types::AuthRequest, ()> for AuthRequest {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::AuthRequest {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::AuthRequest {
let request = match self {
AuthRequest::Login {
email,
Expand Down
5 changes: 4 additions & 1 deletion stremio-core-protobuf/src/bridge/env_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use crate::protobuf::stremio::core::runtime;
use stremio_core::runtime::EnvError;

impl ToProtobuf<runtime::EnvError, ()> for EnvError {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> runtime::EnvError {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> runtime::EnvError {
runtime::EnvError {
code: self.code() as i32,
message: self.message(),
Expand Down
10 changes: 8 additions & 2 deletions stremio-core-protobuf/src/bridge/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ impl ToProtobuf<models::Events, ()> for Events {
}

impl ToProtobuf<models::EventModal, ()> for GetModalResponse {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::EventModal {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::EventModal {
models::EventModal {
id: self.id.to_owned(),
title: self.title.to_owned(),
Expand All @@ -33,7 +36,10 @@ impl ToProtobuf<models::EventModal, ()> for GetModalResponse {
}

impl ToProtobuf<models::EventNotification, ()> for GetNotificationResponse {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::EventNotification {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::EventNotification {
models::EventNotification {
id: self.id.to_owned(),
title: self.title.to_owned(),
Expand Down
5 changes: 4 additions & 1 deletion stremio-core-protobuf/src/bridge/extra_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ impl FromProtobuf<ExtraValue> for types::ExtraValue {
}

impl ToProtobuf<types::ExtraValue, ()> for ExtraValue {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::ExtraValue {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::ExtraValue {
types::ExtraValue {
name: self.name.to_owned(),
value: self.value.to_owned(),
Expand Down
5 changes: 4 additions & 1 deletion stremio-core-protobuf/src/bridge/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use crate::bridge::ToProtobuf;
use crate::protobuf::stremio::core::types;

impl ToProtobuf<types::LinkPreview, ()> for Link {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::LinkPreview {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::LinkPreview {
types::LinkPreview {
name: self.name.to_string(),
category: self.category.to_string(),
Expand Down
4 changes: 3 additions & 1 deletion stremio-core-protobuf/src/bridge/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ impl<T: FromProtobuf<U>, U> FromProtobuf<Vec<U>> for Vec<T> {

impl<T: ToProtobuf<U, A>, U, A> ToProtobuf<Vec<U>, A> for Vec<T> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, args: &A) -> Vec<U> {
self.iter().map(|item| item.to_protobuf::<E>(args)).collect()
self.iter()
.map(|item| item.to_protobuf::<E>(args))
.collect()
}
}
64 changes: 51 additions & 13 deletions stremio-core-protobuf/src/bridge/loadable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ impl
impl ToProtobuf<models::loadable_subtitles::Content, Option<&String>>
for Loadable<Vec<Subtitles>, ResourceError>
{
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, addon_name: &Option<&String>) -> models::loadable_subtitles::Content {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
addon_name: &Option<&String>,
) -> models::loadable_subtitles::Content {
match &self {
Loadable::Ready(ready) => {
models::loadable_subtitles::Content::Ready(models::Subtitles {
Expand All @@ -156,7 +159,10 @@ impl ToProtobuf<models::loadable_subtitles::Content, Option<&String>>
}

impl ToProtobuf<models::LoadableSettings, ()> for Loadable<Settings, EnvError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableSettings {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableSettings {
let content = match &self {
Loadable::Ready(ready) => {
models::loadable_settings::Content::Ready(ready.to_protobuf::<E>(&()))
Expand All @@ -173,7 +179,10 @@ impl ToProtobuf<models::LoadableSettings, ()> for Loadable<Settings, EnvError> {
}

impl ToProtobuf<models::LoadableBaseUrl, ()> for Loadable<Url, EnvError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableBaseUrl {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableBaseUrl {
let content = match &self {
Loadable::Ready(ready) => models::loadable_base_url::Content::Ready(ready.to_string()),
Loadable::Err(error) => models::loadable_base_url::Content::Error(models::Error {
Expand All @@ -188,9 +197,14 @@ impl ToProtobuf<models::LoadableBaseUrl, ()> for Loadable<Url, EnvError> {
}

impl ToProtobuf<models::LoadableCode, ()> for Loadable<LinkCodeResponse, LinkError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableCode {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableCode {
let content = match &self {
Loadable::Ready(ready) => models::loadable_code::Content::Ready(ready.to_protobuf::<E>(&())),
Loadable::Ready(ready) => {
models::loadable_code::Content::Ready(ready.to_protobuf::<E>(&()))
}
Loadable::Err(error) => models::loadable_code::Content::Error(models::Error {
message: error.to_string(),
}),
Expand All @@ -203,7 +217,10 @@ impl ToProtobuf<models::LoadableCode, ()> for Loadable<LinkCodeResponse, LinkErr
}

impl ToProtobuf<models::LoadableAuthKey, ()> for Loadable<LinkAuthKey, LinkError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableAuthKey {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableAuthKey {
let content = match &self {
Loadable::Ready(ready) => {
models::loadable_auth_key::Content::Ready(ready.to_protobuf::<E>(&()))
Expand All @@ -220,7 +237,10 @@ impl ToProtobuf<models::LoadableAuthKey, ()> for Loadable<LinkAuthKey, LinkError
}

impl ToProtobuf<models::LoadableTorrent, ()> for Loadable<ResourcePath, EnvError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableTorrent {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableTorrent {
let content = match &self {
Loadable::Ready(ready) => {
let deeplinks = MetaItemDeepLinks::from(ready).to_protobuf::<E>(&());
Expand All @@ -238,7 +258,10 @@ impl ToProtobuf<models::LoadableTorrent, ()> for Loadable<ResourcePath, EnvError
}

impl ToProtobuf<models::LoadablePlaybackDevices, ()> for Loadable<Vec<PlaybackDevice>, EnvError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadablePlaybackDevices {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadablePlaybackDevices {
let content = match &self {
Loadable::Ready(ready) => {
models::loadable_playback_devices::Content::Ready(PlaybackDevices {
Expand All @@ -261,7 +284,10 @@ impl ToProtobuf<models::LoadablePlaybackDevices, ()> for Loadable<Vec<PlaybackDe
}

impl ToProtobuf<models::LoadableStatistics, ()> for Loadable<Statistics, EnvError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableStatistics {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableStatistics {
let content = match &self {
Loadable::Ready(ready) => {
models::loadable_statistics::Content::Ready(ready.to_protobuf::<E>(&()))
Expand All @@ -280,7 +306,10 @@ impl ToProtobuf<models::LoadableStatistics, ()> for Loadable<Statistics, EnvErro
impl ToProtobuf<models::loadable_addon_catalog::Content, Ctx>
for Loadable<Vec<DescriptorPreview>, ResourceError>
{
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, ctx: &Ctx) -> models::loadable_addon_catalog::Content {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
ctx: &Ctx,
) -> models::loadable_addon_catalog::Content {
match &self {
Loadable::Ready(ready) => {
models::loadable_addon_catalog::Content::Ready(models::Addons {
Expand All @@ -298,7 +327,10 @@ impl ToProtobuf<models::loadable_addon_catalog::Content, Ctx>
}

impl ToProtobuf<models::loadable_descriptor::Content, Ctx> for Loadable<Descriptor, EnvError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, ctx: &Ctx) -> models::loadable_descriptor::Content {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
ctx: &Ctx,
) -> models::loadable_descriptor::Content {
match &self {
Loadable::Ready(ready) => {
models::loadable_descriptor::Content::Ready(ready.to_protobuf::<E>(ctx))
Expand All @@ -312,7 +344,10 @@ impl ToProtobuf<models::loadable_descriptor::Content, Ctx> for Loadable<Descript
}

impl ToProtobuf<models::LoadableModal, ()> for Loadable<Option<GetModalResponse>, CtxError> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableModal {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableModal {
let content = match &self {
Loadable::Ready(ready) => models::loadable_modal::Content::Ready(LoadedModal {
modal: ready.to_protobuf::<E>(&()),
Expand All @@ -335,7 +370,10 @@ impl ToProtobuf<models::LoadableModal, ()> for Loadable<Option<GetModalResponse>
impl ToProtobuf<models::LoadableNotification, ()>
for Loadable<Option<GetNotificationResponse>, CtxError>
{
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> models::LoadableNotification {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> models::LoadableNotification {
let content = match &self {
Loadable::Ready(ready) => {
models::loadable_notification::Content::Ready(LoadedNotification {
Expand Down
35 changes: 28 additions & 7 deletions stremio-core-protobuf/src/bridge/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ impl ToProtobuf<types::ExtraProp, ()> for ExtraProp {
}

impl ToProtobuf<types::ManifestBehaviorHints, ()> for ManifestBehaviorHints {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::ManifestBehaviorHints {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::ManifestBehaviorHints {
types::ManifestBehaviorHints {
adult: self.adult,
p2p: self.p2p,
Expand All @@ -150,7 +153,10 @@ impl ToProtobuf<types::ManifestBehaviorHints, ()> for ManifestBehaviorHints {
}

impl ToProtobuf<types::manifest_extra::Extra, ()> for ManifestExtra {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::manifest_extra::Extra {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::manifest_extra::Extra {
match self {
ManifestExtra::Full { props } => {
types::manifest_extra::Extra::Full(types::FullManifestExtra {
Expand All @@ -169,7 +175,10 @@ impl ToProtobuf<types::manifest_extra::Extra, ()> for ManifestExtra {
}

impl ToProtobuf<types::ManifestCatalog, ()> for ManifestCatalog {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::ManifestCatalog {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::ManifestCatalog {
types::ManifestCatalog {
id: self.id.to_owned(),
r#type: self.r#type.to_owned(),
Expand All @@ -182,7 +191,10 @@ impl ToProtobuf<types::ManifestCatalog, ()> for ManifestCatalog {
}

impl ToProtobuf<types::ManifestResource, ()> for ManifestResource {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::ManifestResource {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::ManifestResource {
match self {
ManifestResource::Short(name) => types::ManifestResource {
name: name.to_owned(),
Expand All @@ -203,7 +215,10 @@ impl ToProtobuf<types::ManifestResource, ()> for ManifestResource {
}

impl ToProtobuf<types::ManifestPreview, ()> for ManifestPreview {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::ManifestPreview {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::ManifestPreview {
types::ManifestPreview {
id: self.id.to_owned(),
version: self.version.to_string(),
Expand Down Expand Up @@ -238,7 +253,10 @@ impl ToProtobuf<types::Manifest, ()> for Manifest {
}

impl ToProtobuf<types::DescriptorFlags, ()> for DescriptorFlags {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::DescriptorFlags {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
_args: &(),
) -> types::DescriptorFlags {
types::DescriptorFlags {
official: self.official,
protected: self.protected,
Expand All @@ -247,7 +265,10 @@ impl ToProtobuf<types::DescriptorFlags, ()> for DescriptorFlags {
}

impl ToProtobuf<types::DescriptorPreview, Ctx> for DescriptorPreview {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, ctx: &Ctx) -> types::DescriptorPreview {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
ctx: &Ctx,
) -> types::DescriptorPreview {
types::DescriptorPreview {
manifest: self.manifest.to_protobuf::<E>(&()),
transport_url: self.transport_url.to_protobuf::<E>(&()),
Expand Down
8 changes: 4 additions & 4 deletions stremio-core-protobuf/src/bridge/meta_preview.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use chrono::Duration;

use stremio_core::deep_links::MetaItemDeepLinks;
use stremio_core::models::ctx::Ctx;
use stremio_core::runtime::Env;
use stremio_core::types::addon::ResourceRequest;
use stremio_core::types::resource::{MetaItemBehaviorHints, MetaItemPreview, PosterShape};

use crate::bridge::{FromProtobuf, ToProtobuf};
// use crate::env::AndroidEnv;
use crate::protobuf::stremio::core::types;

impl FromProtobuf<MetaItemBehaviorHints> for types::MetaItemBehaviorHints {
Expand Down Expand Up @@ -45,7 +45,7 @@ impl FromProtobuf<MetaItemPreview> for types::MetaItemPreview {
}

impl ToProtobuf<types::MetaItemBehaviorHints, ()> for MetaItemBehaviorHints {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::MetaItemBehaviorHints {
fn to_protobuf<E: Env + 'static>(&self, _args: &()) -> types::MetaItemBehaviorHints {
types::MetaItemBehaviorHints {
default_video_id: self.default_video_id.clone(),
featured_video_id: self.featured_video_id.clone(),
Expand All @@ -55,7 +55,7 @@ impl ToProtobuf<types::MetaItemBehaviorHints, ()> for MetaItemBehaviorHints {
}

impl ToProtobuf<types::MetaItemDeepLinks, ()> for MetaItemDeepLinks {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::MetaItemDeepLinks {
fn to_protobuf<E: Env + 'static>(&self, _args: &()) -> types::MetaItemDeepLinks {
types::MetaItemDeepLinks {
meta_details_videos: self.meta_details_videos.clone(),
meta_details_streams: self.meta_details_streams.clone(),
Expand All @@ -65,7 +65,7 @@ impl ToProtobuf<types::MetaItemDeepLinks, ()> for MetaItemDeepLinks {
}

impl ToProtobuf<types::MetaItemPreview, (&Ctx, &ResourceRequest)> for MetaItemPreview {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
fn to_protobuf<E: Env + 'static>(
&self,
(ctx, meta_request): &(&Ctx, &ResourceRequest),
) -> types::MetaItemPreview {
Expand Down
Loading

0 comments on commit bc5fda3

Please sign in to comment.