{"id":51509504,"url":"https://github.com/murphsicles/prost","last_synced_at":"2026-07-08T04:30:57.036Z","repository":{"id":361086773,"uuid":"1253027583","full_name":"murphsicles/prost","owner":"murphsicles","description":"Protocol Buffers Encoding \u0026 Decoding for Zeta","archived":false,"fork":false,"pushed_at":"2026-05-29T05:34:24.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-29T07:26:28.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"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/murphsicles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2026-05-29T05:03:07.000Z","updated_at":"2026-05-29T07:11:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/murphsicles/prost","commit_stats":null,"previous_names":["murphsicles/prost"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/murphsicles/prost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fprost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fprost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fprost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fprost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/murphsicles","download_url":"https://codeload.github.com/murphsicles/prost/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fprost/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35252324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-08T02:00:06.796Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-07-08T04:30:56.298Z","updated_at":"2026-07-08T04:30:57.022Z","avatar_url":"https://github.com/murphsicles.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# prost\n\n[![Zeta](https://img.shields.io/badge/Zeta-Language-%23FF6B6B?style=flat-square)](https://zeta-lang.org)\n[![zorbs.io](https://img.shields.io/badge/zorbs.io-@proto/prost-%2300C4FF?style=flat-square)](https://zorbs.io/@proto/prost)\n[![GitHub](https://img.shields.io/badge/GitHub-murphsicles/prost-%23181717?style=flat-square)](https://github.com/murphsicles/prost)\n\nProtocol Buffers encoding and decoding for Zeta. Prost handles the binary wire format for protobuf messages — the compact, cross-language serialisation protocol used by gRPC, Kafka, and most microservice architectures.\n\n## Quick Start\n\nAdd to your `zorb.toml`:\n\n```toml\n[dependencies]\n@proto/prost = \"1.0\"\n```\n\nEncode and decode Protocol Buffer messages:\n\n```zeta\nuse @proto/prost::{Message, encoding};\n\n// Define a message type implementing the Message trait\nstruct MyMessage {\n    id: i32,\n    name: String,\n    tags: Vec\u003cString\u003e,\n}\n\nimpl Message for MyMessage {\n    fn encode_raw(\u0026self, buf: \u0026mut impl BufMut) {\n        encoding::encode_key(1, WireType::Varint, buf);\n        encoding::encode_varint(self.id as u64, buf);\n        encoding::encode_key(2, WireType::LengthDelimited, buf);\n        encoding::encode_string(\u0026self.name, buf);\n        for tag in \u0026self.tags {\n            encoding::encode_key(3, WireType::LengthDelimited, buf);\n            encoding::encode_string(tag, buf);\n        }\n    }\n\n    fn decode_field(\u0026mut self, tag: u32, wire_type: WireType, buf: \u0026mut impl Buf) -\u003e Result\u003c(), DecodeError\u003e {\n        match tag {\n            1 =\u003e {\n                let val = encoding::decode_varint(buf)?;\n                self.id = val as i32;\n                Ok(())\n            }\n            2 =\u003e {\n                self.name = encoding::decode_string(buf)?;\n                Ok(())\n            }\n            3 =\u003e {\n                let tag_str = encoding::decode_string(buf)?;\n                self.tags.push(tag_str);\n                Ok(())\n            }\n            _ =\u003e Ok(()),\n        }\n    }\n\n    fn encoded_len(\u0026self) -\u003e usize {\n        encoding::key_len(1) + encoding::varint_len(self.id as u64)\n        + encoding::key_len(2) + encoding::string_len(\u0026self.name)\n        + self.tags.iter()\n            .map(|t| encoding::key_len(3) + encoding::string_len(t))\n            .sum::\u003cusize\u003e()\n    }\n\n    fn clear(\u0026mut self) {\n        self.id = 0;\n        self.name.clear();\n        self.tags.clear();\n    }\n}\n\nfn main() {\n    let msg = MyMessage {\n        id: 42,\n        name: \"hello\".into(),\n        tags: vec![\"zeta\".into(), \"protobuf\".into()],\n    };\n\n    // Encode\n    let encoded = msg.encode_to_vec();\n    print(\"Encoded: {} bytes\\n\", encoded.len);\n\n    // Decode\n    let mut decoded = MyMessage::new();\n    decoded.merge(\u0026encoded).unwrap();\n    print(\"Decoded: id={}, name={}\\n\", decoded.id, decoded.name);\n}\n```\n\n## Wire Types\n\n| Type | Tag | Description |\n|------|-----|-------------|\n| `Varint` | 0 | Variable-length integer (int32, int64, uint32, uint64, bool, enum) |\n| `Fixed64` | 1 | 64-bit fixed (fixed64, sfixed64, double) |\n| `LengthDelimited` | 2 | Length-prefixed data (string, bytes, embedded messages, repeated) |\n| `Fixed32` | 5 | 32-bit fixed (fixed32, sfixed32, float) |\n\n## Encoding Utilities\n\n```zeta\nuse @proto/prost::encoding;\n\nfn main() {\n    // Varint encoding\n    let buf = encoding::encode_varint(300).to_vec();   // → [0xAC, 0x02]\n    let val = encoding::decode_varint(Cursor(buf));    // → 300\n\n    // ZigZag encoding (for signed integers)\n    let buf = encoding::encode_varint(encoding::encode_zigzag(-42));\n    let zigged = encoding::encode_zigzag(-42);          // → 83\n    let unzigged = encoding::decode_zigzag(zigged);     // → -42\n\n    // Fixed-size primitives\n    encoding::encode_fixed32(42u32, buf);                // 4 bytes, little-endian\n    encoding::encode_fixed64(42u64, buf);                // 8 bytes, little-endian\n    encoding::encode_float(3.14f32, buf);                // 4 bytes, little-endian\n    encoding::encode_double(3.14f64, buf);               // 8 bytes, little-endian\n}\n```\n\n## Length-Delimited Messages\n\nFor streaming multiple protobuf messages over a single connection:\n\n```zeta\nuse @proto/prost::encoding::length_delimiter;\n\nfn main() {\n    // Encode a length-delimited message\n    let mut buf = Vec::new();\n    length_delimiter::encode_length_delimiter(msg.encoded_len(), \u0026mut buf).unwrap();\n    msg.encode_raw(\u0026mut buf);\n\n    // Decode the length prefix\n    let len = length_delimiter::decode_length_delimiter(Cursor(\u0026buf)).unwrap();\n    // Read `len` bytes for the message body\n}\n```\n\n## API Overview\n\n| Function / Type | Description |\n|----------------|-------------|\n| `Message` trait | Core trait: `encode_raw()`, `decode_field()`, `encoded_len()`, `clear()` |\n| `encoding::encode_varint(val)` | Encode a varint to bytes |\n| `encoding::decode_varint(buf)` | Decode a varint from bytes |\n| `encoding::encode_zigzag(val)` | ZigZag encode a signed integer |\n| `encoding::decode_zigzag(val)` | ZigZag decode back to signed |\n| `encoding::encode_key(tag, wiretype)` | Encode a field key (tag + wire type) |\n| `encoding::encode_string(s)` / `decode_string(buf)` | Length-delimited string encoding |\n| `encoding::encode_float/double/fixed32/fixed64` | Fixed-width primitive encoding |\n| `length_delimiter::encode/decode_length_delimiter()` | Length prefix for streaming |\n| `DecodeError` / `EncodeError` | Error types |\n| `UnknownEnumValue` | Tracks unrecognized enum values |\n| `Name` trait | Type name reflection for proto descriptors |\n\n## Tips\n\n- Use `encoded_len()` to pre-allocate the exact buffer size — much faster than dynamic growth\n- For real protobuf usage, pair prost with a `.proto` file compiler for code generation\n- The `encoding` module gives you full low-level control over the wire format\n- Varint encoding is efficient for small values (\u003c 128) but uses more bytes for large ones — consider fixed32/fixed64 for predictable-size fields\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurphsicles%2Fprost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurphsicles%2Fprost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurphsicles%2Fprost/lists"}