Handle NXM URIs #150

Merged
lucas merged 3 commits from feat/nexus-uri-handler into master 2023-12-01 09:22:09 +01:00
2 changed files with 35 additions and 2 deletions
Showing only changes of commit 4c6ad1aaed - Show all commits

View file

@ -468,7 +468,7 @@ pub(crate) async fn import_from_nxm(state: ActionState, uri: String) -> Result<M
import_mod(state, Some((nexus, file_info.version)), data).await
}
#[tracing::instrument(skip(state))]
#[tracing::instrument(skip(state, data), fields(data = data.len()))]
pub(crate) async fn import_mod(
state: ActionState,
nexus: Option<(NexusInfo, String)>,

View file

@ -95,7 +95,7 @@ impl From<NexusMod> for NexusInfo {
}
}
#[derive(Clone, Data, Debug, Lens)]
#[derive(Clone, Data, Lens)]
pub(crate) struct ModInfo {
pub id: String,
pub name: String,
@ -118,6 +118,39 @@ pub(crate) struct ModInfo {
pub nexus: Option<NexusInfo>,
}
impl std::fmt::Debug for ModInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ModInfo")
.field("id", &self.id)
.field("name", &self.name)
.field("summary", &self.summary)
.field(
"description",
&(match &self.description {
Some(desc) => format!("Some(String[0..{}])", desc.len()),
None => "None".to_string(),
}),
)
.field("categories", &self.categories)
.field("author", &self.author)
.field(
"image",
&(match &self.image {
Some(image) => format!("Some(ImageBuf[{}x{}])", image.width(), image.height()),
None => "None".to_string(),
}),
)
.field("version", &self.version)
.field("enabled", &self.enabled)
.field("packages", &format!("Vec[0..{}]", self.packages.len()))
.field("resources", &self.resources)
.field("depends", &self.depends)
.field("bundled", &self.bundled)
.field("nexus", &self.nexus)
.finish()
}
}
impl ModInfo {
pub fn new(
cfg: ModConfig,