Open
Description
Many common functions in atomic_lib
, like Rersource::new
, take a String
as an argument.
This has some problems:
- We need a lot of
.into_string
- Any functions relating to Subjects are hard to discover (e.g. check if URLs are valid)
We could improve this by:
- Accepting
impl From<String>
, which deals with&str
as well asString
. This is the easy approach that already brings some decent DX improvements. - Accepting a new type for
Subject
, which implementsFrom<String>
anddisplay
.
This second Subject
type deserves some thoughts:
- Subjects are currently practically always
http
URLs. Therefore, it might make sense to simply treat them as URLs - We'll probably introduce a type of
local-id
in the future. There are (probably) still URLs! - We could add some useful features, like a method to check if it's a
local
or not, or what the root of the origin is or something. - If creating a
Subject
requires parsing the string, we should consider performance impact, e.g. when constructing a Resource from a binary blob. Same goes for serialisation! So perhaps URLs are a bit too expensive? - If we use one type for all these subjects, refactoring will be far easier (e.g. if we'll rename
subject
toid
) - In a recent PR, we already have an
AtomicURL
type. This creates a URL under the hood, and provides some methods for getting specific routes / subdomains. Perhaps this could be theID
type?
Metadata
Metadata
Assignees
Labels
No labels