microsoft / Nova

Nova: High-speed recursive arguments from folding schemes
MIT License
673 stars 176 forks source link

support serialize and deserialize for engines #307

Closed RyanKung closed 4 months ago

RyanKung commented 4 months ago

@microsoft-github-policy-service agree [company="{Rings Network}"]

RyanKung commented 4 months ago

@microsoft-github-policy-service agree company="rings network"

srinathsetty commented 4 months ago

Hi @RyanKung Could you please clarify the need for serde on Engine related types?

RyanKung commented 4 months ago

Hi @RyanKung Could you please clarify the need for serde on Engine related types?

My use case is like

use crate::provider::VestaEngine;
use crate::provider::PallasEngine;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Wrap<E1, E2>
where
      E1: Engine<Base = <E2 as Engine>::Scalar>,
      E2: Engine<Base = <E1 as Engine>::Scalar>,
{
    inner: (E1, E2),
}

#[derive(Serialize, Deserialize, Clone)]
enum Example
{
    VestaPallas(Wrap<VestaEngine, PallasEngine>),
    PallasVasta(Wrap<PallasEngine, VestaEngine>),
}

This will cause a compile error:

error[E0277]: the trait bound `VestaEngine: Serialize` is not satisfied
   --> src/lib.rs:855:10
    |
855 | #[derive(Serialize, Deserialize, Clone)]
    |          ^^^^^^^^^ the trait `Serialize` is not implemented for `VestaEngine`
...
858 |     VestaPallas(Wrap<VestaEngine, PallasEngine>),
    |                 ------------------------------- required by a bound introduced by this call
    |
    = help: the following other types implement trait `Serialize`:
              bool
              char
              isize
              i8
              i16
              i32
              i64
              i128
            and 238 others