Skip to content

StructTypes encourage piracy #87

@jakobnissen

Description

@jakobnissen

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions