# The “right” way to define a custom Encoding format?

I have implemented an Import|Export format for xz that behaves like gzip and other encoding formats:

Import["some.ext.gz"]
Import["some.ext.xz"]


But I think I did it in a really roundabout way, is there a more straightforward way than adding DownValues for all these things:

ImportExportEncodingsDumprundecoder["XZ", infile_String, outfile_String, opts___]
ImportExportEncodingsDumprunencoder["XZ", infile_String, outfile_String, opts___]
FileFormatDump$FILEFORMATMATRIX["XZ"] (*$ /mma.SE bug *)
ImportExportEncodingsDumpInstallCoderQ["XZ"]
ImportExportEncodingsDumpCreateShortName[infile_ /; StringMatchQ[infile, "*.xz"]]
AppendTo[FileFormatDump\$FILEFORMATS, "XZ"]


Together with:

ImportExportRegisterImport["XZ", ImportXZ,
"BinaryFormat"->True,
"Extensions"->{"*.xz"},
"Encoding"->True,
"AvailableElements"->{_String},
"FunctionChannels"->{"FileNames"}]
(* Similar for Export *)
`

What's the best way to do this?