ruma icon indicating copy to clipboard operation
ruma copied to clipboard

Encode Metadata `added`<-`deprecated`<-`removed` invariants

Open ShadowJonathan opened this issue 3 years ago • 2 comments

Currently, Metadata just has three Options, which technically could all be None or Some independently

I want to change this so that the invariant of "deprecated implies added" and "removed implies deprecated" is encoded in an enum, possibly something like this;

enum Versioning {
  None,
  WithAdded {
    added: MatrixVersion,
  },
  WithDeprecated {
    added: MatrixVersion,
    deprecated: MatrixVersion,
  },
  WithRemoved {
    added: MatrixVersion,
    deprecated: MatrixVersion,
    removed: MatrixVersion,
  }
}

ShadowJonathan avatar Apr 11 '22 13:04 ShadowJonathan

The idea sounds good, but the variant names seem weird. How about Unstable, Stable, Deprecated, Removed?

jplatte avatar Apr 11 '22 13:04 jplatte

While working on this, I realised it was a bit weird to not include the *_path variables into this as well, considering that they fall almost under the same invariant.

Should I do that as well?

ShadowJonathan avatar Apr 30 '22 11:04 ShadowJonathan

Now that we have VersionHistory with private fields, do we still need this?

jplatte avatar Jan 17 '23 09:01 jplatte

This has basically been enforced by these lines, yeah.

ShadowJonathan avatar Jan 18 '23 13:01 ShadowJonathan