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

Candid type selector #544

Merged
merged 17 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 130 additions & 362 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions rust/candid/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ impl<'a> types::Serializer for &'a mut ValueSerializer {
self.serialize_principal(blob)?;
self.serialize_text(meth)
}
fn serialize_option<T: ?Sized>(self, v: Option<&T>) -> Result<()>
fn serialize_option<T>(self, v: Option<&T>) -> Result<()>
where
T: super::CandidType,
T: super::CandidType + ?Sized,
{
match v {
None => {
Expand Down Expand Up @@ -207,9 +207,9 @@ pub struct Compound<'a> {
}
impl<'a> types::Compound for Compound<'a> {
type Error = Error;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<()>
fn serialize_element<T>(&mut self, value: &T) -> Result<()>
where
T: types::CandidType,
T: types::CandidType + ?Sized,
{
value.idl_serialize(&mut *self.ser)?;
Ok(())
Expand Down
8 changes: 4 additions & 4 deletions rust/candid/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ pub trait Serializer: Sized {
fn serialize_text(self, v: &str) -> Result<(), Self::Error>;
fn serialize_null(self, v: ()) -> Result<(), Self::Error>;
fn serialize_empty(self) -> Result<(), Self::Error>;
fn serialize_option<T: ?Sized>(self, v: Option<&T>) -> Result<(), Self::Error>
fn serialize_option<T>(self, v: Option<&T>) -> Result<(), Self::Error>
where
T: CandidType;
T: CandidType + ?Sized;
fn serialize_struct(self) -> Result<Self::Compound, Self::Error>;
fn serialize_vec(self, len: usize) -> Result<Self::Compound, Self::Error>;
fn serialize_blob(self, v: &[u8]) -> Result<(), Self::Error>;
Expand All @@ -94,9 +94,9 @@ pub trait Serializer: Sized {

pub trait Compound {
type Error;
fn serialize_element<T: ?Sized>(&mut self, v: &T) -> Result<(), Self::Error>
fn serialize_element<T>(&mut self, v: &T) -> Result<(), Self::Error>
where
T: CandidType;
T: CandidType + ?Sized;
// Used for simulating serde(with = "serde_bytes"). We can remove this when specialization is stable in Rust,
// or generalize this function to take a closure for with.
#[doc(hidden)]
Expand Down
9 changes: 4 additions & 5 deletions rust/candid_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ num-bigint.workspace = true
pretty.workspace = true
thiserror.workspace = true
anyhow.workspace = true
serde.workspace = true

lalrpop-util = "0.20.0"
logos = "0.13"
convert_case = "0.6"
handlebars = "5.1"
toml = { version = "0.8", default-features = false, features = ["parse"] }

arbitrary = { workspace = true, optional = true }
# Don't upgrade serde_dhall. It will introduce dependency with invalid license.
serde_dhall = { version = "0.11", default-features = false, optional = true }
fake = { version = "2.4", optional = true }
rand = { version = "0.8", optional = true }
num-traits = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
dialoguer = { version = "0.11", default-features = false, features = ["editor", "completion"], optional = true }
console = { version = "0.15", optional = true }
ctrlc = { version = "3.4", optional = true }
Expand All @@ -48,8 +48,7 @@ test-generator = "0.3.0"
rand.workspace = true

[features]
configs = ["serde_dhall"]
random = ["configs", "arbitrary", "fake", "rand", "num-traits", "serde"]
random = ["dep:arbitrary", "dep:fake", "dep:rand", "dep:num-traits"]
assist = ["dep:dialoguer", "dep:console", "dep:ctrlc"]
all = ["random", "assist"]

Expand Down
Loading
Loading