Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kabergstrom committed Oct 18, 2020
1 parent 0563fd8 commit 50fe5fc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
32 changes: 19 additions & 13 deletions loader/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use std::{
},
};

type Result<T> = std::result::Result<T, Box<dyn Error + Send + 'static>>;

pub trait LoaderIO {
fn get_asset_metadata_with_dependencies(&mut self, request: MetadataRequest);
fn get_asset_candidates(&mut self, requests: Vec<ResolveRequest>);
Expand Down Expand Up @@ -141,24 +143,25 @@ pub struct LoaderState {
responses: IORequestChannels,
}

#[allow(clippy::type_complexity)]
struct IORequestChannels {
data_rx: Receiver<(Result<Vec<u8>, Box<dyn Error + Send>>, LoadHandle, u32)>,
data_tx: Sender<(Result<Vec<u8>, Box<dyn Error + Send>>, LoadHandle, u32)>,
data_rx: Receiver<(Result<Vec<u8>>, LoadHandle, u32)>,
data_tx: Sender<(Result<Vec<u8>>, LoadHandle, u32)>,
metadata_rx: Receiver<(
Result<Vec<ArtifactMetadata>, Box<dyn Error + Send>>,
Result<Vec<ArtifactMetadata>>,
HashMap<AssetUuid, (LoadHandle, u32)>,
)>,
metadata_tx: Sender<(
Result<Vec<ArtifactMetadata>, Box<dyn Error + Send>>,
Result<Vec<ArtifactMetadata>>,
HashMap<AssetUuid, (LoadHandle, u32)>,
)>,
resolve_rx: Receiver<(
Result<Vec<(PathBuf, Vec<AssetMetadata>)>, Box<dyn Error + Send>>,
Result<Vec<(PathBuf, Vec<AssetMetadata>)>>,
IndirectIdentifier,
LoadHandle,
)>,
resolve_tx: Sender<(
Result<Vec<(PathBuf, Vec<AssetMetadata>)>, Box<dyn Error + Send>>,
Result<Vec<(PathBuf, Vec<AssetMetadata>)>>,
IndirectIdentifier,
LoadHandle,
)>,
Expand All @@ -180,9 +183,10 @@ impl AssetLoadResult {
}
}

#[allow(clippy::type_complexity)]
pub struct MetadataRequest {
tx: Sender<(
Result<Vec<ArtifactMetadata>, Box<dyn Error + Send>>,
Result<Vec<ArtifactMetadata>>,
HashMap<AssetUuid, (LoadHandle, u32)>,
)>,
requests: Option<HashMap<AssetUuid, (LoadHandle, u32)>>,
Expand Down Expand Up @@ -212,7 +216,7 @@ impl Drop for MetadataRequest {
}

pub struct DataRequest {
tx: Sender<(Result<Vec<u8>, Box<dyn Error + Send>>, LoadHandle, u32)>,
tx: Sender<(Result<Vec<u8>>, LoadHandle, u32)>,
asset_id: AssetUuid,
artifact_id: ArtifactId,
request_data: Option<(LoadHandle, u32)>,
Expand Down Expand Up @@ -248,9 +252,11 @@ impl Drop for DataRequest {
}
}
}

#[allow(clippy::type_complexity)]
pub struct ResolveRequest {
tx: Sender<(
Result<Vec<(PathBuf, Vec<AssetMetadata>)>, Box<dyn Error + Send>>,
Result<Vec<(PathBuf, Vec<AssetMetadata>)>>,
IndirectIdentifier,
LoadHandle,
)>,
Expand Down Expand Up @@ -678,7 +684,7 @@ impl LoaderState {
error!("metadata request failed: {}", err);
}
}
for (_, (handle, version)) in request_data {
for (handle, version) in request_data.values() {
let mut load = self
.load_states
.get_mut(&handle)
Expand Down Expand Up @@ -1182,7 +1188,7 @@ impl Loader {
&mut self,
asset_storage: &dyn AssetStorage,
resolver: &dyn IndirectionResolver,
) -> Result<(), Box<dyn Error>> {
) -> Result<()> {
self.io.tick(&mut self.data);
self.data.process_asset_changes(asset_storage);
self.data.process_load_ops(asset_storage);
Expand Down Expand Up @@ -1239,7 +1245,7 @@ fn commit_asset(
#[cfg(test)]
mod tests {
use super::*;
use crate::{rpc_state::RpcIO, TypeUuid};
use crate::{rpc_io::RpcIO, DefaultIndirectionResolver, TypeUuid};
use atelier_core::AssetUuid;
use atelier_daemon::{init_logging, AssetDaemon};
use atelier_importer::{AsyncImporter, ImportedAsset, ImporterValue, Result as ImportResult};
Expand Down Expand Up @@ -1412,7 +1418,7 @@ mod tests {
break;
}
std::thread::sleep(std::time::Duration::from_millis(10));
if let Err(e) = loader.process(storage) {
if let Err(e) = loader.process(storage, &DefaultIndirectionResolver) {
println!("err {:?}", e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions loader/src/rpc_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::loader::{DataRequest, LoaderIO, LoaderState, MetadataRequest, Resolve
type Promise<T> = capnp::capability::Promise<T, capnp::Error>;

struct RpcConnection {
asset_hub: asset_hub::Client,
_asset_hub: asset_hub::Client,
snapshot: asset_hub::snapshot::Client,
snapshot_rx: Receiver<SnapshotChange>,
}
Expand Down Expand Up @@ -150,7 +150,7 @@ impl RpcRuntime {
.promise
.await
.map(|_| RpcConnection {
asset_hub: hub,
_asset_hub: hub,
snapshot,
snapshot_rx,
})
Expand Down
2 changes: 1 addition & 1 deletion schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn parse_artifact_metadata(artifact: &data::artifact_metadata::Reader<'_>) -
Some(uncompressed_size)
};
ArtifactMetadata {
asset_id: asset_id,
asset_id,
id: ArtifactId(u64::from_le_bytes(make_array(
artifact.get_hash().expect("capnp: failed to read hash"),
))),
Expand Down

0 comments on commit 50fe5fc

Please sign in to comment.