Skip to content

Commit

Permalink
updated workflow, toml, readme and removed PhantomData usage as not r…
Browse files Browse the repository at this point in the history
…equired
  • Loading branch information
mburridge96 committed Apr 19, 2024
1 parent 9d33a0e commit bec86f2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
create-release:
runs-on: ubuntu-latest
# Use a container with GLIBC 2.17
container: quay.io/pypa/manylinux2014_x86_64
steps:
- name: Show GLIBC
run: ldd --version
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --manifest-path cli/Cargo.toml
- name: Upload binary
uses: actions/upload-artifact@4
with:
name: cli-tool
path: cli

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ reqwest = { version = "0.11", features = ["blocking", "json"], default-features

[dev-dependencies]
tempfile = "3.9"

2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Overview

pycrate is a python library that is built upon a rust backend for interfacing with [RO-Crates](https://www.researchobject.org/ro-crate/1.1/). It's designed to be maximally flexible with minimal onboarding, allowing you to incorprate it into scrpits/ data pipelines as easily as possible. This also relies on you to have an understanding of the structure of an RO-Crate, but focuses more on the fact that some metadata is better than no metadata.
rocraters is a python library that is built upon a rust backend for interfacing with [RO-Crates](https://www.researchobject.org/ro-crate/1.1/). It's designed to be maximally flexible with minimal onboarding, allowing you to incorprate it into scrpits/ data pipelines as easily as possible. This also relies on you to have an understanding of the structure of an RO-Crate, but focuses more on the fact that some metadata is better than no metadata.

# Build

Expand Down
14 changes: 2 additions & 12 deletions src/ro_crate/metadata_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use serde::{
};
use std::collections::HashMap;
use std::fmt;
use std::marker::PhantomData;

/// Represents the metadata descriptor for entire RoCrate.
///
Expand Down Expand Up @@ -140,19 +139,12 @@ pub trait CustomSerialize: Serialize {
/// `@id`, `@type`, `conformsTo`, and `about` keys to populate the corresponding fields
/// of `MetadataDescriptor`. All other keys are treated as dynamic properties and are
/// stored in the `dynamic_entity` hashmap.
///
/// # Implementation Details
/// `MetadataDescriptorVisitor` uses `PhantomData` to correctly implement the `Visitor` trait
/// without needing an actual instance of `MetadataDescriptor`. This allows the visitor to be
/// generic over the `MetadataDescriptor` type, ensuring type safety and correctness.
impl<'de> Deserialize<'de> for MetadataDescriptor {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct MetadataDescriptorVisitor {
marker: PhantomData<fn() -> MetadataDescriptor>,
}
struct MetadataDescriptorVisitor;

impl<'de> Visitor<'de> for MetadataDescriptorVisitor {
type Value = MetadataDescriptor;
Expand Down Expand Up @@ -203,9 +195,7 @@ impl<'de> Deserialize<'de> for MetadataDescriptor {
}
}

deserializer.deserialize_map(MetadataDescriptorVisitor {
marker: PhantomData,
})
deserializer.deserialize_map(MetadataDescriptorVisitor)
}
}

Expand Down

0 comments on commit bec86f2

Please sign in to comment.