-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Suppose I have a package, in which I need to serialize some data that contain a LongDNA{4}
, but do not want to expose the private (non-documented) memory layout of LongDNA
. In that case, I'd need to overwrite StructTypes.StructType(::Type{LongDNA{4}})
- or, alternatively, overwrite some JSON3 methods.
Both are type piracy, which can have rather bad consequences. For example, it's unknown to me if the user installs another package which also need to serialize LongDNA
, but may choose to do it differently. In that case, my code may randomly malfunction.
I don't see a non-breaking way of getting around it, but perhaps it's worth considering for a potential breaking release in the future:
- This package defines a
struct AbstractEncoder end
- Struct mapping is done by
StructTypes.StructType(::AbstractEncoder, ::Type{MyType})
- Default struct mapping can use
::AbstractEncoder directly.
- Users can then subtype
AbstractEncoder
, and create struct mapping using their own subtype.
Metadata
Metadata
Assignees
Labels
No labels