Feature: async trait #11

已合併
igalic 4 年之前 將 8 次代碼提交從 plume/webfinger:feat/async-trait 合併至 main
igalic " 評論 4 年之前" (Migrated from github.com)

add a feature (behind a off-by-default flag) to use async trait implementations.

add a feature (behind a off-by-default flag) to use async trait implementations.
igalic " 評論 4 年之前" (Migrated from github.com)

for now, this doesn't work, because impl String is not (necessarily) Send safe.

for now, this doesn't work, because `impl String` is not (necessarily) `Send` safe.
igalic " 評論 4 年之前" (Migrated from github.com)

current status:

meena@76ix ~/s/a/webfinger (feat/async-trait)> cargo +nightly build --features async
   Compiling webfinger v0.5.0 (/home/meena/src/ap/webfinger)
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
 --> src/async_trait.rs:8:1
  |
8 | #[async_trait]
  | ^^^^^^^^^^^^^^ explicit generic argument not allowed
  |
  = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

error: could not compile `webfinger`.

To learn more, run the command again with --verbose.
meena@76ix ~/s/a/webfinger (feat/async-trait) [101]> 
current status: ``` meena@76ix ~/s/a/webfinger (feat/async-trait)> cargo +nightly build --features async Compiling webfinger v0.5.0 (/home/meena/src/ap/webfinger) error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position --> src/async_trait.rs:8:1 | 8 | #[async_trait] | ^^^^^^^^^^^^^^ explicit generic argument not allowed | = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error error: could not compile `webfinger`. To learn more, run the command again with --verbose. meena@76ix ~/s/a/webfinger (feat/async-trait) [101]> ```
codecov[bot] " 評論 4 年之前" (Migrated from github.com)

Codecov Report

Merging #11 into main will increase coverage by 2.68%.
The diff coverage is 96.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
+ Coverage   91.39%   94.07%   +2.68%     
==========================================
  Files           2        4       +2     
  Lines         151      287     +136     
==========================================
+ Hits          138      270     +132     
- Misses         13       17       +4     
Impacted Files Coverage Δ
src/lib.rs 86.45% <81.25%> (-1.43%) ⬇️
src/tests.rs 97.54% <98.50%> (+3.42%) ⬆️
src/async_resolver.rs 100.00% <100.00%> (ø)
src/resolver.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c494677...e2b2b37. Read the comment docs.

# [Codecov](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=h1) Report > Merging [#11](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=desc) into [main](https://codecov.io/gh/Plume-org/webfinger/commit/9f1e0e7074d466cf62a618a5c2bb785e50c0c27c&el=desc) will **increase** coverage by `2.68%`. > The diff coverage is `96.39%`. [![Impacted file tree graph](https://codecov.io/gh/Plume-org/webfinger/pull/11/graphs/tree.svg?width=650&height=150&src=pr&token=9gTr9Sg00C)](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=tree) ```diff @@ Coverage Diff @@ ## main #11 +/- ## ========================================== + Coverage 91.39% 94.07% +2.68% ========================================== Files 2 4 +2 Lines 151 287 +136 ========================================== + Hits 138 270 +132 - Misses 13 17 +4 ``` | [Impacted Files](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=tree) | Coverage Δ | | |---|---|---| | [src/lib.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL2xpYi5ycw==) | `86.45% <81.25%> (-1.43%)` | :arrow_down: | | [src/tests.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL3Rlc3RzLnJz) | `97.54% <98.50%> (+3.42%)` | :arrow_up: | | [src/async\_resolver.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL2FzeW5jX3Jlc29sdmVyLnJz) | `100.00% <100.00%> (ø)` | | | [src/resolver.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL3Jlc29sdmVyLnJz) | `100.00% <100.00%> (ø)` | | ------ [Continue to review full report at Codecov](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=continue). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta) > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=footer). Last update [c494677...e2b2b37](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
igalic " 評論 4 年之前" (Migrated from github.com)

back to building, now we need to add a test for async.

This: https://gist.github.com/a5727727c2f55be6f37e937bfc232d32 is not it: https://gist.github.com/ae41ec328a2a443fa02214a4b0f19281

back to building, now we need to add a test for async. This: https://gist.github.com/a5727727c2f55be6f37e937bfc232d32 is not it: https://gist.github.com/ae41ec328a2a443fa02214a4b0f19281
trinity-1686a approved these changes 4 年之前
trinity-1686a left a comment
所有者

LGTM

I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr

LGTM I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr
@ -0,0 +9,4 @@
pub trait AsyncResolver {
type Repo: Send;
/// Returns the domain name of the current instance.
async fn instance_domain<'a>(&self) -> &'a str;
所有者

I'm not sure this requires to be async, I would expect an implementation to return one of its fields, but I guess there is nothing wrong with too much async, it'll just get optimized away during monomorphisation

I'm not sure this requires to be async, I would expect an implementation to return one of its fields, but I guess there is nothing wrong with too much async, it'll just get optimized away during monomorphisation
igalic (Migrated from github.com) reviewed 4 年之前
@ -0,0 +9,4 @@
pub trait AsyncResolver {
type Repo: Send;
/// Returns the domain name of the current instance.
async fn instance_domain<'a>(&self) -> &'a str;
igalic (Migrated from github.com) " 評論 4 年之前"

and if it's async in the trait signature, it means you can use await in the function body.

and if it's `async` in the trait signature, it means you can use `await` in the function body.
igalic " 評論 4 年之前" (Migrated from github.com)

LGTM

I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr

how do you suggest improving those?
ideally, i'd like to do that before a next release, because, more importantly, i'd like to call the next release '1.0'

> LGTM > > I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr how do you suggest improving those? ideally, i'd like to do that before a next release, because, more importantly, i'd like to call the next release '1.0'
所有者

hum, endpoint() rely way more on find() than I though so in fact any incorrectness on a valid answer would come from find(), never mind my comment

hum, endpoint() rely way more on find() than I though so in fact any incorrectness on a valid answer would come from find(), never mind my comment

Reviewers

trinity-1686a approved these changes 4 年之前
The pull request has been merged as 4e8f12810c.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b feat/async-trait main
git pull origin feat/async-trait

Step 2:

Merge the changes and update on Forgejo.
git checkout main
git merge --no-ff feat/async-trait
git push origin main
登入 才能加入這對話。
No reviewers
未選擇里程碑
No Assignees
2 參與者
訊息
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: plume/webfinger#11
Loading…
尚未有任何內容