Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,38 +152,40 @@ jobs:
commit_user_email: github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# How to create a new GitHub release?
# 1. Create a release branch named "release/<tag>".
# 2. Open a PR from the branch, including the release note in the PR body.
# 3. Wait for the CI to create a draft release.
# 4. Publish the release when it's ready.
release:
name: Create GitHub release
needs: [check, changelog]
if: startsWith(github.head_ref, 'release/')
if: startsWith(github.head_ref, 'release/') && github.repository == 'loichyan/dynify'
permissions:
contents: write # Need to update release
contents: write # need to update release
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v4

# For a PR from "release/v1.0.0", the release tag is set to "v1.0.0"
- name: Setup | Configure
id: configure
run: echo tag="${GITHUB_HEAD_REF#release/}" >$GITHUB_OUTPUT

# Release notes are taken from the PR's body
- name: Release | Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_tag: ${{ steps.configure.outputs.tag }}
release_body: ${{ github.event.pull_request.body }}
run: |
if gh release view "$release_tag" &>/dev/null; then
echo "update existed release $release_tag"
command=edit
if gh release view "$release_tag" >/dev/null; then
echo "update existing release $release_tag"
gh release edit "$release_tag" --notes="$release_body"
else
echo "create new release $release_tag"
command=create
gh release create "$release_tag" \
--target="$GITHUB_BASE_REF" \
--draft=true \
--title="${release_tag#v} ($(date -u +'%Y-%m-%d'))" \
--notes="$release_body"
fi
gh release "$command" "$release_tag" \
--target="$GITHUB_BASE_REF" \
--draft=true \
--title="$release_tag ($(date -u +'%Y-%m-%d'))" \
--notes="$release_body"
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ changes.
[README](https://github.com/loichyan/dynify/blob/v0.0.1/README.md) for more
details.

[0.0.1]: https://github.com/loichyan/dynify/releases/tag/v0.0.1
[0.1.0]: https://github.com/loichyan/dynify/releases/tag/v0.1.0
[0.1.1]: https://github.com/loichyan/dynify/releases/tag/v0.1.1
[0.0.1]: https://github.com/loichyan/dynify/tree/v0.0.1
[0.1.0]: https://github.com/loichyan/dynify/compare/v0.0.1..v0.1.0
[0.1.1]: https://github.com/loichyan/dynify/compare/v0.1.0..v0.1.1
[Unreleased]: https://github.com/loichyan/dynify/compare/v0.1.1..HEAD
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ for limited environments. In contrast, async-trait requires heap allocation to
store trait objects, as it essentially transforms `async fn` into
`Box<dyn Future>`.

### vs dynosaur

[dynosaur](https://crates.io/crates/dynosaur) employs the same approach as
async-trait to generate dyn compatible traits but, by default, preserves the
original trait for more performant static dispatch. Similar to the async-trait
case, the main advantage of using dynify is the possibility to achieve heapless
dynamic dispatch.

## ♥️ Special thanks

- [Rust-for-Linux/pin-init](https://github.com/Rust-for-Linux/pin-init) for its
Expand Down
16 changes: 15 additions & 1 deletion src/dynify.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ trait DynTrait {
In common cases, you can rely on the lifetimes generated by `#[dynify]`, adding
extra bounds as needed.

## Making [`Send`]able generated traits
## Making generated traits [`Send`]able

Unlike `async-trait`, this macro does not provide support for adding `Send`
bounds to returned `Future`s (or any other `impl Trait`s). However, as
Expand All @@ -136,3 +136,17 @@ fn run_client(
}
}
```

As an alternative, you can also [bitte](https://crates.io/crates/bitte) for this
purpose:

<!-- TODO: enable doctest after we move to edition 2024 -->

```rust,ignore
# use dynify::PinDynify;
#[bitte::bitte(Send)]
#[dynify::dynify] // must be put within the scope of `#[bitte]`
trait Client {
async fn request(&self, uri: &str) -> String;
}
```
Loading