{"id":17861205,"url":"https://github.com/jonathanstowe/messagepack-class","last_synced_at":"2025-07-16T06:42:43.254Z","repository":{"id":66980428,"uuid":"88279280","full_name":"jonathanstowe/MessagePack-Class","owner":"jonathanstowe","description":"Serialize/Deserialize Raku classes to/from MessagePack blobs","archived":false,"fork":false,"pushed_at":"2022-08-07T08:44:59.000Z","size":20,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T02:03:20.343Z","etag":null,"topics":["deserialization","messagepack","raku"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanstowe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-14T15:26:38.000Z","updated_at":"2022-08-07T08:45:02.000Z","dependencies_parsed_at":"2023-05-16T10:00:23.973Z","dependency_job_id":null,"html_url":"https://github.com/jonathanstowe/MessagePack-Class","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonathanstowe/MessagePack-Class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FMessagePack-Class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FMessagePack-Class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FMessagePack-Class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FMessagePack-Class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanstowe","download_url":"https://codeload.github.com/jonathanstowe/MessagePack-Class/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FMessagePack-Class/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265489079,"owners_count":23775247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deserialization","messagepack","raku"],"created_at":"2024-10-28T08:43:20.905Z","updated_at":"2025-07-16T06:42:43.216Z","avatar_url":"https://github.com/jonathanstowe.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MessagePack::Class\n\nSerialize/Deserialize Raku classes to/from MessagePack blobs\n\n![Build Status](https://github.com/jonathanstowe/Tinky/workflows/CI/badge.svg)\n\n\n## Synopsis\n\n```raku\n\nuse MessagePack::Class;\n\nclass MyClass does MessagePack::Class {\n\thas Str $.some-data;\n}\n\nmy Blob $pack = MyClass.new(some-data =\u003e \"whatever\").to-messagepack;\n\n# Then send $pack over the network, write it to a file or something\n\nmy MyClass $obj = MyClass.from-messagepack($pack);\n\n\n```\n\n## Description\n\n[MessagePack](http://msgpack.org/) is a binary serialization format that\nis particularly efficient for transmission over a network or file storage.\n\nThis module provides a role that allows for the direct serialization of\na Raku object to a MessagePack binary blob and the deserialization of\nthat blob back to a Raku object of the same type with the same attribute\nvalues.\n\nUnder the hood it uses [Data::MessagePack](https://github.com/pierre-vigier/Perl6-Data-MessagePack)\nto serialize and deserialize data structures representing the object in a very\nsimilar manner to [JSON::Marshal](https://github.com/jonathanstowe/JSON-Marshal) and\n[JSON::Unmarshal](https://github.com/tadzik/JSON-Unmarshal) (infact it borrows some\nof the internal code of both of those to construct a suitable data structure.)\n\nFor a simple case this may work with your class unchanged apart from the addition of\nthe role composition, however for types that may not be properly constructed from\ntheir public attributes there are provided the attribute traits ```packed-by``` and\n```unpacked-by``` which allow you to provide either a subroutine or a method name\nthat will work with a representation that will round-trip properly.\n\nA named method supplied to ```packed-by``` will be called on the object to be serialized\nwithout any arguments and should return a value suitable for serialization, and a method\nsupplied to ```unpacked-by``` will be called on the type object with the value to be\ndeserialized as a single positional argument and should return an object of the type.\n\nSo for instance if one had a class with an attribute of type Version one might do:\n\n```\nclass TraitTest does MessagePack::Class {\n    has Version $.version is packed-by('Str') is unpacked-by('new');\n}\n```\n\nWhere the ```Str``` method returns a string that is suitable to be passed to ```new```\nto create a new Version  object.\n\nIf a subroutine (or other Callable object) is passed to the traits then it should take\na single argument and return a value suitable for serialization (for ```packed-by```) or\nan object of the appropriate type (for ```unpacked-by```) so the above example might\nbecome:\n\n```\nclass TraitTest does MessagePack::Class {\n    has Version $.version is packed-by(-\u003e Version $v { $v.Str }) is unpacked-by(-\u003e Str $v { Version.new($v)});\n}\n```\n\nYou can of course make the subroutines as complex as is required for your types.\n\nIf you need your data to be interoperable with software written in another language\nyou may need to adjust the serialization accordingly to match the types available\nin that language.\n\n## Installation\n\nAssuming you have a working Rakudo installation the you should be able to install this with ```zef``` :\n\n    zef install MessagePack::Class\n\n    # or from a local check-out:\n\n    zef install .\n\nThough I can't see any reason this shouldn't work with any other installer that may come along in the future.\n\nIf it reports that is having trouble installing the dependency, you can do:\n\n    zef install -v --debug https://github.com/pierre-vigier/Perl6-Data-MessagePack.git\n\n## Support\n\nIf you find a problem with this module or have a suggestion please report at\nhttps://github.com/jonathanstowe/MessagePack-Class/issues - though I always\nprefer a pull request with tests if you can do that.\n\n## Licence and Copyright\n\nThis is free software. Please see the [LICENCE](LICENCE) file in this repository.\n\n© Jonathan Stowe 2017 - 2021\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Fmessagepack-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanstowe%2Fmessagepack-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Fmessagepack-class/lists"}