{"id":18790669,"url":"https://github.com/onsails/prosto","last_synced_at":"2025-10-15T17:46:41.866Z","repository":{"id":40310914,"uuid":"272416027","full_name":"onsails/prosto","owner":"onsails","description":"Compress prost! messages with zstd, async streams support","archived":false,"fork":false,"pushed_at":"2025-06-18T07:38:32.000Z","size":105,"stargazers_count":4,"open_issues_count":14,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-17T21:32:50.401Z","etag":null,"topics":["async","compression","futures","google-protobuf","protobuf","streams","zstd"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/onsails.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2020-06-15T11:04:55.000Z","updated_at":"2023-09-07T08:06:35.000Z","dependencies_parsed_at":"2023-01-21T08:45:19.059Z","dependency_job_id":"27bb0065-fe08-405a-b1ce-d3586b00d5c2","html_url":"https://github.com/onsails/prosto","commit_stats":{"total_commits":100,"total_committers":4,"mean_commits":25.0,"dds":"0.32999999999999996","last_synced_commit":"b1705da9488bfb8673517dac3e02364afc77a911"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/onsails/prosto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onsails%2Fprosto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onsails%2Fprosto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onsails%2Fprosto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onsails%2Fprosto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onsails","download_url":"https://codeload.github.com/onsails/prosto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onsails%2Fprosto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265810008,"owners_count":23831945,"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":["async","compression","futures","google-protobuf","protobuf","streams","zstd"],"created_at":"2024-11-07T21:13:13.373Z","updated_at":"2025-10-15T17:46:36.833Z","avatar_url":"https://github.com/onsails.png","language":"Rust","readme":"# Compress prost! messages with zstd, async streams support\n\n[![docs](https://docs.rs/prosto/badge.svg)](https://docs.rs/prosto)\n\n## Simple compress/decompress\n\n```rust\nfn do_roundtrip_coders(level: i32, dummies: Vec\u003cproto::Dummy\u003e) {\n    tracing_subscriber::fmt::try_init().ok();\n\n    let writer = vec![];\n    let mut encoder = ProstEncoder::new(writer, level).unwrap();\n    for dummy in \u0026dummies {\n        encoder.write(dummy).unwrap();\n    }\n    let compressed = encoder.finish().unwrap();\n\n    let mut decoder = ProstDecoder::\u003cproto::Dummy\u003e::new_decompressed(\u0026compressed[..]).unwrap();\n\n    let mut i: usize = 0;\n    while let Some(dummy) = decoder.next() {\n        let dummy = dummy.unwrap();\n        assert_eq!(\u0026dummy, dummies.get(i).unwrap());\n        i += 1;\n    }\n\n    assert_eq!(dummies.len(), i);\n}\n```\n\n## Async streams support\n\n`enable-async` Cargo feature (enabled by default) exposes `Compressor` and `Decompressor` structs:\n\n* `Compressor::build_stream` converts a stream of prost! messages to a stream of bytes;\n* `Decompressor::stream` converts a stream of compressed bytes to a stream of prost! messages.\n\nDespite this example utilizes tokio channels, this crate does not depend on tokio, it's just used in tests.\n\n```rust\nfn do_roundtrip_channels(chunk_size: usize, level: i32, dummies: Vec\u003cproto::Dummy\u003e) {\n    tracing_subscriber::fmt::try_init().ok();\n\n    let mut rt = Runtime::new().unwrap();\n\n    // Dummy source ~\u003e Compressor\n    let (mut source, dummy_rx) = mpsc::channel::\u003cproto::Dummy\u003e(dummies.len());\n    // Compressor ~\u003e Decompressor\n    let (compressed_tx, compressed_rx) = mpsc::channel::\u003cVec\u003cu8\u003e\u003e(dummies.len());\n    // Decompressor ~\u003e Dummy sink\n    let (dummy_tx, mut sink) = mpsc::channel::\u003cproto::Dummy\u003e(dummies.len());\n\n    let compressor = Compressor::build_stream(dummy_rx, level, chunk_size).unwrap();\n    let decompressor = Decompressor::stream(compressed_rx);\n\n    rt.block_on(async move {\n        let compress_task = tokio::task::spawn(\n            compressor\n                .map_err(anyhow::Error::new)\n                .try_fold(compressed_tx, |mut ctx, compressed| async {\n                    ctx.send(compressed)\n                        .await\n                        .map_err(|_| anyhow!(\"Failed to send compressed\"))?;\n                    Ok(ctx)\n                })\n                .map_ok(|_| ()),\n        );\n        let decompress_task = tokio::task::spawn(\n            decompressor\n                .map_err(anyhow::Error::new)\n                .try_fold(dummy_tx, |mut utx, message| async {\n                    utx.send(message)\n                        .await\n                        .map_err(|_| anyhow!(\"Failed to send decompressed\"))?;\n                    Ok(utx)\n                })\n                .map_ok(|_| ()),\n        );\n\n        for dummy in \u0026dummies {\n            source\n                .send(dummy.clone())\n                .await\n                .map_err(|_| anyhow!(\"Failed to send to source\"))\n                .unwrap();\n        }\n\n        std::mem::drop(source);\n\n        let mut i: usize = 0;\n        while let Some(dummy) = sink.recv().await {\n            assert_eq!(\u0026dummy, dummies.get(i).unwrap());\n            i += 1;\n        }\n\n        let (compress, decompress) =\n            futures::try_join!(compress_task, decompress_task).unwrap();\n        compress.unwrap();\n        decompress.unwrap();\n        assert_eq!(dummies.len(), i);\n    });\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonsails%2Fprosto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonsails%2Fprosto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonsails%2Fprosto/lists"}