{"id":15563924,"url":"https://github.com/mrsarm/rust-sum-queue","last_synced_at":"2026-03-05T05:31:18.261Z","repository":{"id":48874920,"uuid":"272502782","full_name":"mrsarm/rust-sum-queue","owner":"mrsarm","description":"Rust :crab: queue struct that keeps a fixed number of items by time, not capacity, and allows to get summarized stats of its content","archived":false,"fork":false,"pushed_at":"2023-08-25T23:00:57.000Z","size":46,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T02:39:10.266Z","etag":null,"topics":["algorithms","caching","data-structures","queue","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/sum-queue/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrsarm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2020-06-15T17:30:26.000Z","updated_at":"2023-06-15T01:33:42.000Z","dependencies_parsed_at":"2024-10-02T16:30:31.044Z","dependency_job_id":"e888c2ca-6731-48f0-95de-d5f5dcc733ea","html_url":"https://github.com/mrsarm/rust-sum-queue","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":"0.040000000000000036","last_synced_commit":"8eb011f37a475def1c2b779b49ebad552cd7c5ce"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mrsarm/rust-sum-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsarm%2Frust-sum-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsarm%2Frust-sum-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsarm%2Frust-sum-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsarm%2Frust-sum-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrsarm","download_url":"https://codeload.github.com/mrsarm/rust-sum-queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsarm%2Frust-sum-queue/sbom","scorecard":{"id":664761,"data":{"date":"2025-08-11","repo":{"name":"github.com/mrsarm/rust-sum-queue","commit":"842e2fd41bb51faaede5a583d362585de1e09e94"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 2/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rust.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/mrsarm/rust-sum-queue/rust.yml/master?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/rust.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: COPYING:0","Info: FSF or OSI recognized license: GNU Lesser General Public License v3.0: COPYING:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T17:36:32.525Z","repository_id":48874920,"created_at":"2025-08-21T17:36:32.525Z","updated_at":"2025-08-21T17:36:32.525Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30111743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"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":["algorithms","caching","data-structures","queue","rust"],"created_at":"2024-10-02T16:30:22.433Z","updated_at":"2026-03-05T05:31:18.234Z","avatar_url":"https://github.com/mrsarm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"sum-queue\n=========\n\n`SumQueue` it's a **Rust** queue type that keeps a fixed number of\nitems by time, not capacity, similar to a cache, but with a simpler\nand faster implementation. It also allows to get summarized stats\nof the values on it at any time.\n\n## Examples\n\n```rust\nuse std::time::Duration;\nuse std::thread;\nuse sum_queue::SumQueue;\n\n// creates a queue where elements expire after 2 seconds\nlet mut queue: SumQueue\u003ci32\u003e = SumQueue::new(Duration::from_secs(2));\nqueue.push(1);\nqueue.push(10);\nqueue.push(3);\n\n// Check the peek without removing the element\nassert_eq!(queue.peek(), Some(\u00261));\n// elements are removed in the same order were pushed\nassert_eq!(queue.pop(), Some(1));\nassert_eq!(queue.pop(), Some(10));\nassert_eq!(queue.pop(), Some(3));\nassert_eq!(queue.pop(), None);\n\n// Lets puts elements again\nqueue.push(1);\nqueue.push(5);\nqueue.push(2);\n// Elements can be iterated as many times as you want\nprintln!(\"heap data: {:?}\", queue.iter().collect::\u003cVec\u003c_\u003e\u003e());  // [1, 5, 2]\n\n// Check stats\nlet stats = queue.stats();\nprintln!(\"Stats - min value in queue: {}\", stats.min.unwrap());         // 1\nprintln!(\"Stats - max value in queue: {}\", stats.max.unwrap());         // 5\nprintln!(\"Stats - sum all values in queue: {}\", stats.sum.unwrap());    // 8\nprintln!(\"Stats - length of queue: {}\", stats.len);                     // 3\n\nassert_eq!(queue.pop(), Some(1));\nassert_eq!(queue.iter().collect::\u003cVec\u003c_\u003e\u003e(), vec![\u00265, \u00262]);\nprintln!(\"Elements after pop: {:?}\", queue.iter().collect::\u003cVec\u003c_\u003e\u003e()); // [5, 2]\n\n// After a second the elements are still the same\nthread::sleep(Duration::from_secs(1));\nprintln!(\"Same after 1 sec: {:?}\", queue.iter().collect::\u003cVec\u003c_\u003e\u003e());   // [5, 2]\n\nqueue.push(50); // Add an element 1 second younger than the rest of elements\nprintln!(\"Same elements + 50: {:?}\", queue.iter().collect::\u003cVec\u003c_\u003e\u003e()); // [5, 2, 50]\n\n// Now let sleep 1 sec so the first elements expire\nthread::sleep(Duration::from_secs(1));\nprintln!(\"Just 50: {:?}\", queue.iter().collect::\u003cVec\u003c_\u003e\u003e());            // [50]\n\n// 1 second more later the last element also expires\nthread::sleep(Duration::from_secs(1));\nprintln!(\"No elements: {:?}\", queue.iter().collect::\u003cVec\u003c_\u003e\u003e());        // []\n```\n\n## Implementation\n\nUnderneath uses a [BinaryHeap](https://doc.rust-lang.org/std/collections/binary_heap/struct.BinaryHeap.html)\nstruct to keep the values, and implements the same methods: `push()`, `pop()`, `peek()` ...\nalthough worth to note that the implementations of the `SumQueue` type take mutable\nownership of the `self` reference (eg. `peek(\u0026mut self) -\u003e Option\u003c\u0026T\u003e`). That is\nbecause the cleaning of the expired elements of the queue occurs each time\na method is called to read or write a value, including the `len()` method.\n\nSo as long you manage only one instance of `SumQueue`, there is no\nrisk of excessive memory allocation, because while you push elements with the `push()`\nmethod, or call any other method to read the queue you are taking care of removing\nand deallocating the expired elements, but if you are using multiple instances, and\npushing too many items to some queues and not accessing others further, the memory usage\nmay growth with elements expired not been deallocated because you are not accessing\nthose queues to push, pop or get the stats of them. In that case you can at least\ntry to call often to the `len()` method to force the unused queues to remove and\ndeallocate the expired elements.\n\n\n## About\n\n**Source**: https://github.com/mrsarm/rust-sum-queue\n\n**Authors**: (2020-2021) Mariano Ruiz \u003cmrsarm@gmail.com\u003e\n\n**Documentation**: https://docs.rs/sum-queue/\n\n**License**: LGPL-3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsarm%2Frust-sum-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrsarm%2Frust-sum-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsarm%2Frust-sum-queue/lists"}