You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
Sorry if this sounds like a question more than an issue, but I thought it'd be better to have this here so other people can find some information about it if they try to use helix in a similar way. This question might also be driven by my lack of knowledge about Rust, keep that in mind.
I have a crate that I'd like to reuse in several projects, one of them being a Rails application. This crate defines several public structures. I'm copying here the basic information about that crate so you don't have to switch contexts, but you can find it here: https://github.com/calavera/netlify-toml-rs.
/// Config represents the full configuration within a netlify.toml file.
#[derive(Serialize, Deserialize)]
pub struct Config {
pub build: Option<Context>,
pub context: Option<HashMap<String, Context>>,
// Other fields, not relevant for this example
}
/// Context holds the build variables Netlify uses to build a site before deploying it.
#[derive(Serialize, Deserialize)]
pub struct Context {
pub base: Option<String>,
pub publish: Option<String>,
pub command: Option<String>,
pub functions: Option<String>,
pub environment: Option<HashMap<String, String>>,
}
Those structures are used to deserialize a TOML document using toml-rs:
Ideally, I'd like to serialize that Config into a Ruby class directly, I think I need to implement the ToRuby trait, but I'm not sure how to make that work, or if it'd work. I was considering having something like this:
But then, I'd also like to reuse some functions that Config implements.
As a last resort, I would be ok with reimplementing that crate with helix classes and struct definitions directly, but when I tried to use the serde's derive annotations, I got a parser error when I did this:
ruby! {
#[derive(Serialize, Deserialize)]
class Config {
...
}
}
I'd really appreciate some guidance. Having examples to do this would be awesome, ultimately, I wouldn't mind to contribute them myself if I can make that work.
👋
The text was updated successfully, but these errors were encountered:
Hi,
Sorry if this sounds like a question more than an issue, but I thought it'd be better to have this here so other people can find some information about it if they try to use helix in a similar way. This question might also be driven by my lack of knowledge about Rust, keep that in mind.
I have a crate that I'd like to reuse in several projects, one of them being a Rails application. This crate defines several public structures. I'm copying here the basic information about that crate so you don't have to switch contexts, but you can find it here:
https://github.com/calavera/netlify-toml-rs.
Those structures are used to deserialize a TOML document using
toml-rs
:Ideally, I'd like to serialize that
Config
into a Ruby class directly, I think I need to implement theToRuby
trait, but I'm not sure how to make that work, or if it'd work. I was considering having something like this:But then, I'd also like to reuse some functions that
Config
implements.As a last resort, I would be ok with reimplementing that crate with helix classes and struct definitions directly, but when I tried to use the serde's
derive
annotations, I got a parser error when I did this:I'd really appreciate some guidance. Having examples to do this would be awesome, ultimately, I wouldn't mind to contribute them myself if I can make that work.
👋
The text was updated successfully, but these errors were encountered: