{"id":16936467,"url":"https://github.com/jonhoo/async-lease","last_synced_at":"2025-10-11T01:36:31.730Z","repository":{"id":57500635,"uuid":"174563971","full_name":"jonhoo/async-lease","owner":"jonhoo","description":"An asynchronous leased value","archived":false,"fork":false,"pushed_at":"2019-11-08T18:08:18.000Z","size":10,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-26T14:52:05.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonhoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-08T15:44:12.000Z","updated_at":"2024-07-07T06:39:46.000Z","dependencies_parsed_at":"2022-08-30T21:01:12.798Z","dependency_job_id":null,"html_url":"https://github.com/jonhoo/async-lease","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonhoo/async-lease","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fasync-lease","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fasync-lease/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fasync-lease/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fasync-lease/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonhoo","download_url":"https://codeload.github.com/jonhoo/async-lease/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fasync-lease/sbom","scorecard":{"id":531025,"data":{"date":"2025-08-11","repo":{"name":"github.com/jonhoo/async-lease","commit":"9c9dd191924364f57e2f6735a8b6cbf4a11182c0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":-1,"reason":"no dependencies found","details":null,"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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Code-Review","score":0,"reason":"Found 0/6 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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"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":"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":"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":"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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":"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"}}]},"last_synced_at":"2025-08-20T05:44:29.899Z","repository_id":57500635,"created_at":"2025-08-20T05:44:29.899Z","updated_at":"2025-08-20T05:44:29.899Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005929,"owners_count":26083986,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"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":"2024-10-13T20:57:02.999Z","updated_at":"2025-10-11T01:36:31.691Z","avatar_url":"https://github.com/jonhoo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async-lease\n\n[![Crates.io](https://img.shields.io/crates/v/async-lease.svg)](https://crates.io/crates/async-lease)\n[![Documentation](https://docs.rs/async-lease/badge.svg)](https://docs.rs/async-lease/)\n[![Build Status](https://travis-ci.com/jonhoo/async-lease.svg?branch=master)](https://travis-ci.com/jonhoo/async-lease)\n[![Codecov](https://codecov.io/github/jonhoo/async-lease/coverage.svg?branch=master)](https://codecov.io/gh/jonhoo/async-lease)\n\nAn asynchronous, atomic option type intended for use with methods that move `self`.\n\nThis module provides `Lease`, a type that acts similarly to an asynchronous `Mutex`, with one\nmajor difference: it expects you to move the leased item _by value_, and then _return it_ when\nyou are done. You can think of a `Lease` as an atomic, asynchronous `Option` type, in which we\ncan `take` the value only if no-one else has currently taken it, and where we are notified when\nthe value has returned so we can try to take it again.\n\nThis type is intended for use with methods that take `self` by value, and _eventually_, at some\nlater point in time, return that `Self` for future use. This tends to happen particularly often\nin future-related contexts. For example, consider the following method for a hypothetical,\nnon-pipelined connection type:\n\n```rust\nimpl Connection {\n    fn get(self, key: i64) -\u003e impl Future\u003cItem = (i64, Self), Error = Error\u003e;\n}\n```\n\nLet's say you want to expose an interface that does _not_ consume `self`, but instead has a\n`poll_ready` method that checks whether the connection is ready to receive another request:\n\n```rust\nimpl MyConnection {\n    fn poll_ready(\u0026mut self) -\u003e Poll\u003c(), Error = Error\u003e;\n    fn call(\u0026mut self, key: i64) -\u003e impl Future\u003cItem = i64, Error = Error\u003e;\n}\n```\n\n`Lease` allows you to do this. Specifically, `poll_ready` attempts to acquire the lease using\n`Lease::poll_acquire`, and `call` _transfers_ that lease into the returned future. When the\nfuture eventually resolves, we _restore_ the leased value so that `poll_ready` returns `Ready`\nagain to anyone else who may want to take the value. The example above would thus look like\nthis:\n\n```rust\nimpl MyConnection {\n    fn poll_ready(\u0026mut self) -\u003e Poll\u003c(), Error = Error\u003e {\n        self.lease.poll_acquire()\n    }\n\n    fn call(\u0026mut self, key: i64) -\u003e impl Future\u003cItem = i64, Error = Error\u003e {\n        // We want to transfer the lease into the future\n        // and leave behind an unacquired lease.\n        let mut lease = self.lease.transfer();\n        lease.take().get(key).map(move |(v, connection)| {\n            // Give back the connection for other callers.\n            // After this, `poll_ready` may return `Ok(Ready)` again.\n            lease.restore(connection);\n            // And yield just the value.\n            v\n        })\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Fasync-lease","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonhoo%2Fasync-lease","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Fasync-lease/lists"}