truth
truth copied to clipboard
Handling of Encoded in Meta conversions
Option 1: Add Encoding as context to ToMeta/FromMeta
Advantages:
Changes are generally straightforward to make.
Problems with this solution:
- Big signature changes. ToMeta becomes fallible.
pub trait FromMeta<'a>: Sized { - fn from_meta(meta: &'a Sp<Meta>) -> Result<Self, FromMetaError<'a>>; + fn from_meta(meta: &'a Sp<Meta>, cfg: &FromMetaContext) -> Result<Self, FromMetaError<'a>>; } pub trait ToMeta { + fn to_meta(&self, cfg: &ToMetaContext) -> Result<Meta, SimpleError>; } - Annoyingness of
cfgin impls:.get_field(cfg, "field")- If we try to eliminate the
cfgparameter ofget_fieldby adding&'a FromMetaContexttoParseObjectthen we end up with annoying lifetime problems due toimpl FnOnce(&mut ParseObject)parameters. Either need to make itParseObject<'a, 'c>, or we need to makeFromMetatake&'a FromMetaContext.
FromMetaneeds aCustom(crate::error::CompileError),variant.
Option 2: AnmFile<S> and similar
Summary
compile/decompilewill useAnmFile<String>write_to_stream/read_from_streamwill useAnmFile<Encoded>
Advantages:
- Changes are made almost exclusively to
anm.rs,std.rs,msg.rs, andcli_defs.rs. - We might want a separate pass for conversion of args to blobs? This could go hand-in-hand with that. (and then that would be the only pass that needs to know anything about the encoding; nice separation of concerns)
Problems with this solution:
- How will we do these errors if the
"subdir/file.png"is now anEncodedstring of unknown encoding?error: entry for 'subdir/file.png' is missing required field 'width'! (if this data is available in an existing anm file, try using `-i ANM_FILE`)