This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88a8086
commit e4a227a
Showing
5 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use global_error::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::util::task::TaskCtx; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Input {} | ||
|
||
#[derive(Serialize)] | ||
pub struct Output { | ||
pub port: u16, | ||
} | ||
|
||
pub struct Task; | ||
|
||
impl super::Task for Task { | ||
type Input = Input; | ||
type Output = Output; | ||
|
||
fn name() -> &'static str { | ||
"backend_choose_local_port" | ||
} | ||
|
||
async fn run(_task: TaskCtx, _input: Self::Input) -> GlobalResult<Self::Output> { | ||
let port = unwrap!(portpicker::pick_unused_port(), "no free ports"); | ||
Ok(Output { port }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters