-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: introduce support for different tokio
library versions
- Loading branch information
Showing
10 changed files
with
165 additions
and
62 deletions.
There are no files selected for viewing
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
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
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
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,32 @@ | ||
use core::str; | ||
|
||
use crate::{version::Version, version_specialized}; | ||
|
||
version_specialized!(TokioVersion, "Tokio SemVer version"); | ||
|
||
impl Default for TokioVersion { | ||
fn default() -> Self { | ||
// the first supported version is default | ||
TokioVersion(Version((1, 40, 0))) | ||
} | ||
} | ||
|
||
/// Temporary function, parse tokio version from static string found in `rodata`` section. | ||
/// | ||
/// WAITFORFIX: https://github.com/tokio-rs/tokio/issues/6950 | ||
pub fn extract_version_naive(rodata: &[u8]) -> Option<TokioVersion> { | ||
const TOKIO_V_TPL: &str = "tokio-1."; | ||
|
||
let tpl = TOKIO_V_TPL.as_bytes(); | ||
let pos = rodata.windows(tpl.len()).position(|w| w == tpl)?; | ||
|
||
// get next number between dots | ||
let mut pos = pos + tpl.len(); | ||
let mut minor = vec![]; | ||
while rodata[pos] != b'.' || pos >= rodata.len() { | ||
minor.push(rodata[pos]); | ||
pos += 1; | ||
} | ||
let minor = str::from_utf8(&minor).ok()?; | ||
Some(TokioVersion(Version((1, minor.parse().ok()?, 0)))) | ||
} |
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