Add FromRef implementation for generic Aero types

This commit is contained in:
Diggory Blake 2023-08-14 10:58:22 +01:00
parent 1f885d066b
commit 7cd323a0fa
No known key found for this signature in database
GPG key ID: E6BDFA83146ABD40
2 changed files with 9 additions and 2 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "aerosol" name = "aerosol"
version = "1.0.0-alpha.6" version = "1.0.0-alpha.7"
authors = ["Diggory Blake <diggsey@googlemail.com>"] authors = ["Diggory Blake <diggsey@googlemail.com>"]
edition = "2018" edition = "2018"
description = "Simple dependency injection for Rust" description = "Simple dependency injection for Rust"

View file

@ -14,8 +14,9 @@ use axum::{
http::{request::Parts, StatusCode}, http::{request::Parts, StatusCode},
response::{IntoResponse, Response}, response::{IntoResponse, Response},
}; };
use frunk::HCons;
use crate::{Aero, AsyncConstructibleResource, ConstructibleResource, Resource}; use crate::{Aero, AsyncConstructibleResource, ConstructibleResource, Resource, ResourceList};
/// Type of axum Rejection returned when a resource cannot be acquired /// Type of axum Rejection returned when a resource cannot be acquired
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
@ -96,3 +97,9 @@ where
.map_err(DependencyError::failed_to_construct::<T>) .map_err(DependencyError::failed_to_construct::<T>)
} }
} }
impl<H: Resource, T: ResourceList> FromRef<Aero<HCons<H, T>>> for Aero {
fn from_ref(input: &Aero<HCons<H, T>>) -> Self {
input.clone().into()
}
}