{"id":32164989,"url":"https://github.com/matiascr/etiquette","last_synced_at":"2026-03-10T01:31:03.020Z","repository":{"id":307099563,"uuid":"1007359155","full_name":"matiascr/etiquette","owner":"matiascr","description":"Etiquette is a library that allows you to write packet specifications in an ergonomic way.","archived":false,"fork":false,"pushed_at":"2025-10-16T17:06:34.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-21T14:57:12.097Z","etag":null,"topics":["library","protocols"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/etiquette","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matiascr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-23T21:49:57.000Z","updated_at":"2025-10-16T17:06:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd5d7475-ff0b-4d7d-b3f3-455f0bea7506","html_url":"https://github.com/matiascr/etiquette","commit_stats":null,"previous_names":["matiascr/etiquette"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/matiascr/etiquette","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matiascr%2Fetiquette","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matiascr%2Fetiquette/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matiascr%2Fetiquette/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matiascr%2Fetiquette/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matiascr","download_url":"https://codeload.github.com/matiascr/etiquette/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matiascr%2Fetiquette/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30320885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["library","protocols"],"created_at":"2025-10-21T14:57:10.930Z","updated_at":"2026-03-10T01:31:03.004Z","avatar_url":"https://github.com/matiascr.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Etiquette\n\n\u003ca href=\"https://hex.pm/packages/etiquette\"\u003e\u003cimg alt=\"Hex Version\" src=\"https://img.shields.io/hexpm/v/etiquette\"\u003e\u003c/a\u003e\n\u003ca href=\"https://hexdocs.pm/etiquette\"\u003e\u003cimg alt=\"Hex Docs\" src=\"http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat\"\u003e\u003c/a\u003e\n\n\u003cbr\u003e\n\nA new way of creating and following a protocol\n\n## Summary\n\nFollowing an example Header Packet\n\n\u003ctable aria-label=\"Header Packet\"\u003e\n  \u003ctr\u003e\n    \u003cth colspan=\"8\"\u003eByte 0\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"1\"\u003eHeader Fixed\u003c/td\u003e\n    \u003ctd colspan=\"2\"\u003ePacket Type\u003c/td\u003e\n    \u003ctd colspan=\"5\"\u003eType-Specific fields\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nWe can turn it into\n\n```elixir\ndefmodule Example.Spec do\n  use Etiquette.Spec\n\n  packet \"Header Packet\", id: :header_packet do\n    field \"Header Fixed\", 1, fixed: 1, doc: \"Whether the packet is a header.\"\n    field \"Packet Type\", 2, doc: \"The type of the payload. Can be any 0-3 integer.\"\n    field \"Type-Specific fields\", (..), id: :type_specific_fields, doc: \"The packet payload.\"\n  end\n\n  packet \"Hello Packet\", of: :header_packet do\n    field \"Packet Type\", 2, fixed: 0b00\n    field \"Hello-specific payload\", 8, part_of: :type_specific_fields\n  end\n\n  packet \"Conversation Packet\", of: :header_packet do\n    field \"Packet Type\", 2, fixed: 0b01\n    field \"Conversation-specific payload\", 8, part_of: :type_specific_fields\n  end\n\n  packet \"Bye Packet\", of: :header_packet do\n    field \"Packet Type\", 2, fixed: 0b11\n    field \"Bye-specific payload\", 8, part_of: :type_specific_fields\n  end\nend\n```\n\nSuch that we now have a specification\n\n```elixir\niex\u003e Example.Spec.is_header_packet?(\u003c\u003c1::1, \"A random string inside 30 bytes\"::30\u003e\u003e)\ntrue\n\niex\u003e Example.Spec.is_hello_packet?(\u003c\u003c1::1, 0b00::2, \"rest\"\u003e\u003e)\ntrue\n\niex\u003e Example.Spec.is_hello_packet?(\u003c\u003c1::1, 0b10::2, \"rest\"\u003e\u003e)\nfalse\n\niex\u003e Example.Spec.is_bye_packet?(\u003c\u003c1::1, 0b11::2, 0xFF, 0xAA\u003e\u003e)\ntrue\n\niex\u003e Example.Spec.parse_bye_packet(\u003c\u003c1::1, 0b11::2, 0xFF, 0xAA\u003e\u003e)\n{\n  %{\n    header_fixed: 1,\n    packet_type: 3,\n    bye_specific_payload: 255\n  },\n  \u003c\u003c170\u003e\u003e\n}\n\niex\u003e # Notice how only the fields that are not fixed need to be provided\niex\u003e Example.Spec.build_bye_packet(0xFF) |\u003e Example.Spec.parse_bye_packet()\n{\n  %{\n    header_fixed: 1,\n    packet_type: 3,\n    bye_specific_payload: 0xFF\n  },\n  \"\"\n}\n\n\niex\u003e Example.Spec.build_bye_packet(0xFF) |\u003e Example.Spec.is_bye_packet?()\ntrue\n```\n\nNot only are the functions available and functional, but the provided\ndocumentation and other arguments are also analyzed to provide in-depth\ndocumentation of each generated function:\n\n![example_function_help](https://github.com/user-attachments/assets/9e50be09-4f6b-401a-bb9c-32ae702ef0db)\n\n![example_function_help_2](https://github.com/user-attachments/assets/fd02b75b-a698-497e-ae2e-65c74a68a0fb)\n\n![example_function_help_3](https://github.com/user-attachments/assets/7f1fe3fa-2134-49ff-98d7-bb970ef8c71d)\n\n# Future work\n\n- [ ] Add support for frames. Add the option to provide a list of frames as part\n      of a frames field/payload. It should have a similar structure and options\n      to `Etiquette.Spec.packet/3`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatiascr%2Fetiquette","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatiascr%2Fetiquette","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatiascr%2Fetiquette/lists"}