Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/wasm pack #10

Merged
merged 30 commits into from
Jun 13, 2024
Merged

Feature/wasm pack #10

merged 30 commits into from
Jun 13, 2024

Conversation

maebli
Copy link
Owner

@maebli maebli commented Jun 11, 2024

I've added wasm package.

I am looking into using serde crate. Need to know if this is correct.

Serde should be avilable in cli and wasm but not as an option in the lib

@maebli maebli self-assigned this Jun 11, 2024
Cargo.toml Outdated
@@ -28,15 +28,19 @@ bindgen = "0.69.4"
[features]
std = []
plaintext-before-extension = []
serde_support = ["serde", "std", "arrayvec/serde"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this feature to just serde than make the array
["dep:serde", "std", "arrayvec/serde"]
also it is necessary to enable std to use serde? I don't think you need std to use serde

Cargo.toml Outdated
arrayvec = "0.7.4"
arrayvec = { version = "0.7.4", features = [
"serde",
], optional = true, default-features = false }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is arrayvec really optional? You seem to use it without a feature gate in the code.
I think you just want
arrayvec = { version = "0.7.4", default-features = false }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arrayvec/serde feature flag will enable the serde feature on arrayvec when necessary

feature = "serde_support",
derive(serde::Deserialize),
serde(bound(deserialize = "'de: 'a"))
)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can probably be the same cfg_attr. You don't need a separate one for each derive.

#[cfg_attr(
    feature = "serde_support",
    derive(serde::Serialize, serde::Deserialize),
    serde(bound(deserialize = "'de: 'a"))
)]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was not possible

#[derive(Debug, PartialEq)]
pub struct DataInformationBlock {
pub data_information_field: DataInformationField,
#[serde(skip_serializing, skip_deserializing)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also be in a cfg_attr

StatusField::from_bits(bits)
.ok_or_else(|| serde::de::Error::custom("Invalid bits for StatusField"))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can derive these with cfg_attr in the bitflags macro.

Copy link
Owner Author

@maebli maebli Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow this was not working. Where do I need to put it?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-06-12 at 21 44 00

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what error does it show? I am doing this cargo check and it shows no error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you also need to add bitflags/serde to the serde feature flag

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made a pr with this #11

wasm/src/lib.rs Outdated

#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bitflags = "2.4.2"
arrayvec = "0.7.4"
arrayvec = { version = "0.7.4", optional = false, default-features = true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to say optional = false. It has no effect so you can leave it.

@maebli maebli marked this pull request as ready for review June 13, 2024 21:36
@maebli maebli merged commit c439f4c into main Jun 13, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants