Skip to content

Commit

Permalink
chore: address PR review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
  • Loading branch information
elpiel committed Oct 18, 2024
1 parent 72bbd76 commit 3586458
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 96 deletions.
30 changes: 0 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions stremio-core-protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ edition = "2021"
authors = ["Smart Code OOD", "Lachezar Lechev <lachezar@ambire.com>"]

[features]
default = ["model-deser"]
model-deser = ["dep:stremio-core-web"]
default = []

[dependencies]
stremio-core.workspace = true
stremio-core-web = { workspace = true, optional = true }

# Protobuf
prost.workspace = true
Expand Down
26 changes: 4 additions & 22 deletions stremio-core-protobuf/src/bridge/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ use stremio_core::{
runtime::{msg::Event, RuntimeEvent},
};

use crate::bridge::ToProtobuf;
use crate::stremio_core_models::runtime::{self, Field};
use crate::{
bridge::ToProtobuf,
stremio_core_models::runtime::{self, Field},
};

impl ToProtobuf<runtime::Event, ()> for Event {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> runtime::Event {
Expand Down Expand Up @@ -213,26 +215,6 @@ impl ToProtobuf<runtime::Event, ()> for Event {
}
}

// impl ToProtobuf<runtime::RuntimeEvent, ()> for RuntimeEvent<AndroidEnv, AndroidModel> {
// fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> runtime::RuntimeEvent {
// let event = match self {
// RuntimeEvent::NewState(fields, ..) => {
// runtime::runtime_event::Event::NewState(runtime::runtime_event::NewState {
// fields: fields
// .to_protobuf::<E>(&())
// .iter()
// .map(|field| *field as i32)
// .collect(),
// })
// }
// RuntimeEvent::CoreEvent(event) => {
// runtime::runtime_event::Event::CoreEvent(event.to_protobuf::<E>(&()))
// }
// };
// runtime::RuntimeEvent { event: Some(event) }
// }
// }

impl<E, M, F> ToProtobuf<runtime::RuntimeEvent, ()> for RuntimeEvent<E, M>
where
E: stremio_core::runtime::Env + 'static,
Expand Down
44 changes: 14 additions & 30 deletions stremio-core-protobuf/src/bridge/resource_loadable.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
use inflector::Inflector;
use url::Url;

use stremio_core::deep_links::DiscoverDeepLinks;
use stremio_core::models::common::{DescriptorLoadable, ResourceLoadable};
use stremio_core::models::ctx::Ctx;
use stremio_core::types::addon::{DescriptorPreview, ResourceRequest};
use stremio_core::types::library::LibraryItem;
use stremio_core::types::resource::{MetaItem, MetaItemPreview, Stream, Subtitles};
use stremio_core::types::watched_bitfield::WatchedBitField;
use stremio_core::{
deep_links::DiscoverDeepLinks,
models::{
common::{DescriptorLoadable, ResourceLoadable},
ctx::Ctx,
},
types::{
addon::{DescriptorPreview, ResourceRequest},
library::LibraryItem,
resource::{MetaItem, MetaItemPreview, Stream, Subtitles},
watched_bitfield::WatchedBitField,
},
};

use crate::bridge::ToProtobuf;
use crate::protobuf::stremio::core::models;
// use crate::stremio_core_models::types::ResourcePath;

// impl<'a> ToProtobuf<models::LoadablePage, Ctx> for stremio_core_web::model::serialize_catalogs_with_extra::ResourceLoadable<'a> {
// fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, ctx: &Ctx) -> models::LoadablePage {
// let deep_links = DiscoverDeepLinks::from(&self.request).to_protobuf::<E>(&());
// models::LoadablePage {
// title: self.name.to_string(),
// request: crate::protobuf::stremio::core::types::ResourceRequest {
// base: "todo".into(),
// path: ResourcePath {
// resource: "todo".to_string(),
// r#type: "todo".into(),
// id: "todo".into(),
// extra: vec![],
// },
// },
// content: self.content.to_protobuf::<E>(&(ctx, &self.request)),
// deep_links,
// }
// }
// }
use crate::{bridge::ToProtobuf, protobuf::stremio::core::models};

impl ToProtobuf<models::LoadablePage, Ctx> for ResourceLoadable<Vec<MetaItemPreview>> {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
Expand Down
11 changes: 0 additions & 11 deletions stremio-core-protobuf/src/model/fields/catalogs_with_extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ impl ToProtobuf<models::CatalogsWithExtra, Ctx> for CatalogsWithExtra {
}
}

#[cfg(feature = "model-deser")]
impl stremio_core_web::model::SerializeModel<Vec<u8>> for models::CatalogsWithExtra {
type Error = ();

fn serialize_model(&self) -> Result<Vec<u8>, Self::Error> {
use prost::Message;

Ok(self.clone().encode_to_vec())
}
}

impl ToProtobuf<models::DiscoverDeepLinks, ()> for DiscoverDeepLinks {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(
&self,
Expand Down

0 comments on commit 3586458

Please sign in to comment.