You've already forked AstralRinth
forked from didirus/AstralRinth
Updating + Profile Repairs + Performance Improvements (#97)
* repairing * Main framework for updating * add jsconfig * more work * Improve performance * Finish updating * run lint
This commit is contained in:
@@ -144,6 +144,22 @@ pub async fn fetch_mirrors(
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
pub async fn read_json<T>(
|
||||
path: &Path,
|
||||
semaphore: &RwLock<Semaphore>,
|
||||
) -> crate::Result<T>
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
{
|
||||
let io_semaphore = semaphore.read().await;
|
||||
let _permit = io_semaphore.acquire().await?;
|
||||
|
||||
let json = fs::read(path).await?;
|
||||
let json = serde_json::from_slice::<T>(&json)?;
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(bytes, semaphore))]
|
||||
pub async fn write<'a>(
|
||||
path: &Path,
|
||||
|
||||
@@ -14,11 +14,3 @@ macro_rules! wrap_ref_builder {
|
||||
it
|
||||
}};
|
||||
}
|
||||
|
||||
/// Alias a trait, used to avoid needing nightly features
|
||||
macro_rules! alias_trait {
|
||||
($scope:vis $name:ident : $bound:path $(, $bounds:path)*) => {
|
||||
$scope trait $name: $bound $(+ $bounds)* {}
|
||||
impl<T: $bound $(+ $bounds)*> $name for T {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user