fix: Implement std::fmt::Display for Permission to resolve compilation errors
This commit is contained in:
parent
20895c98ff
commit
7d83255051
2 changed files with 14 additions and 100 deletions
|
|
@ -1,9 +1,8 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use strum::{Display, EnumString};
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Display, EnumString)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
pub enum Permission {
|
||||
Read,
|
||||
Write,
|
||||
|
|
@ -12,6 +11,18 @@ pub enum Permission {
|
|||
Admin,
|
||||
}
|
||||
|
||||
impl fmt::Display for Permission {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Read => write!(f, "read"),
|
||||
Self::Write => write!(f, "write"),
|
||||
Self::Delete => write!(f, "delete"),
|
||||
Self::Share => write!(f, "share"),
|
||||
Self::Admin => write!(f, "admin"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Permission {
|
||||
pub fn can_read(&self) -> bool {
|
||||
matches!(self, Self::Read | Self::Admin)
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
candidate #3: `KeyInit`
|
||||
candidate #4: `KeyIvInit`
|
||||
candidate #5: `Mac`
|
||||
candidate #6: `VariableOutput`
|
||||
candidate #7: `VariableOutputCore`
|
||||
candidate #8: `ahash::HashMapExt`
|
||||
candidate #9: `ahash::HashSetExt`
|
||||
candidate #10: `bitvec::store::BitStore`
|
||||
candidate #11: `nonzero_ext::NonZero`
|
||||
candidate #12: `parking_lot_core::thread_parker::ThreadParkerT`
|
||||
candidate #13: `radium::Radium`
|
||||
candidate #14: `rand::distr::uniform::UniformSampler`
|
||||
candidate #15: `rand::distributions::uniform::UniformSampler`
|
||||
candidate #16: `ring::aead::BoundKey`
|
||||
candidate #17: `serde_with::duplicate_key_impls::error_on_duplicate::PreventDuplicateInsertsMap`
|
||||
candidate #18: `serde_with::duplicate_key_impls::error_on_duplicate::PreventDuplicateInsertsSet`
|
||||
candidate #19: `serde_with::duplicate_key_impls::first_value_wins::DuplicateInsertsFirstWinsMap`
|
||||
candidate #20: `serde_with::duplicate_key_impls::first_value_wins::DuplicateInsertsFirstWinsSet`
|
||||
candidate #21: `serde_with::duplicate_key_impls::last_value_wins::DuplicateInsertsLastWinsSet`
|
||||
candidate #22: `trust_dns_proto::Executor`
|
||||
error[E0599]: no function or associated item named `new` found for struct `PasswordService` in the current scope
|
||||
--> src/models/user.rs:117:49
|
||||
|
|
||||
117 | let password_service = PasswordService::new();
|
||||
| ^^^ function or associated item not found in `PasswordService`
|
||||
|
|
||||
::: src/auth/password.rs:10:1
|
||||
|
|
||||
10 | pub struct PasswordService;
|
||||
| -------------------------- function or associated item `new` not found for this struct
|
||||
|
|
||||
= help: items from traits can only be used if the trait is implemented and in scope
|
||||
= note: the following traits define an item `new`, perhaps you need to implement one of them:
|
||||
candidate #1: `Bit`
|
||||
candidate #2: `Digest`
|
||||
candidate #3: `KeyInit`
|
||||
candidate #4: `KeyIvInit`
|
||||
candidate #5: `Mac`
|
||||
candidate #6: `VariableOutput`
|
||||
candidate #7: `VariableOutputCore`
|
||||
candidate #8: `ahash::HashMapExt`
|
||||
candidate #9: `ahash::HashSetExt`
|
||||
candidate #10: `bitvec::store::BitStore`
|
||||
candidate #11: `nonzero_ext::NonZero`
|
||||
candidate #12: `parking_lot_core::thread_parker::ThreadParkerT`
|
||||
candidate #13: `radium::Radium`
|
||||
candidate #14: `rand::distr::uniform::UniformSampler`
|
||||
candidate #15: `rand::distributions::uniform::UniformSampler`
|
||||
candidate #16: `ring::aead::BoundKey`
|
||||
candidate #17: `serde_with::duplicate_key_impls::error_on_duplicate::PreventDuplicateInsertsMap`
|
||||
candidate #18: `serde_with::duplicate_key_impls::error_on_duplicate::PreventDuplicateInsertsSet`
|
||||
candidate #19: `serde_with::duplicate_key_impls::first_value_wins::DuplicateInsertsFirstWinsMap`
|
||||
candidate #20: `serde_with::duplicate_key_impls::first_value_wins::DuplicateInsertsFirstWinsSet`
|
||||
candidate #21: `serde_with::duplicate_key_impls::last_value_wins::DuplicateInsertsLastWinsSet`
|
||||
candidate #22: `trust_dns_proto::Executor`
|
||||
error[E0277]: the trait bound `fn(State<AppState>, ..., ...) -> ... {setup_recovery}: Handler<_, _>` is not satisfied
|
||||
--> src/main.rs:100:49
|
||||
|
|
||||
100 | .route("/api/auth/recovery/setup", post(handlers::setup_recovery))
|
||||
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Handler<_, _>` is not implemented for fn item `fn(State<AppState>, Claims, Json<...>) -> ... {setup_recovery}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= note: Consider using `#[axum::debug_handler]` to improve the error message
|
||||
help: the following other types implement trait `Handler<T, S>`
|
||||
--> /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.7.9/src/routing/method_routing.rs:1309:1
|
||||
|
|
||||
1309 | / impl<S> Handler<(), S> for MethodRouter<S>
|
||||
1310 | | where
|
||||
1311 | | S: Clone + 'static,
|
||||
| |_______________________^ `MethodRouter<S>` implements `Handler<(), S>`
|
||||
|
|
||||
::: /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.7.9/src/handler/mod.rs:303:1
|
||||
|
|
||||
303 | / impl<H, S, T, L> Handler<T, S> for Layered<L, H, T, S>
|
||||
304 | | where
|
||||
305 | | L: Layer<HandlerService<H, T, S>> + Clone + Send + 'static,
|
||||
306 | | H: Handler<T, S>,
|
||||
... |
|
||||
310 | | T: 'static,
|
||||
311 | | S: 'static,
|
||||
| |_______________^ `axum::handler::Layered<L, H, T, S>` implements `Handler<T, S>`
|
||||
note: required by a bound in `post`
|
||||
--> /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.7.9/src/routing/method_routing.rs:443:1
|
||||
|
|
||||
443 | top_level_handler_fn!(post, POST);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^----^^^^^^^
|
||||
| | |
|
||||
| | required by a bound in this function
|
||||
| required by this bound in `post`
|
||||
= note: the full name for the type has been written to '/app/target/debug/deps/normogen_backend-d569d515f613fad5.long-type-4867908669310830501.txt'
|
||||
= note: consider using `--verbose` to print the full type name to the console
|
||||
= note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
Some errors have detailed explanations: E0277, E0282, E0308, E0432, E0433, E0599, E0609, E0659.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
warning: `normogen-backend` (bin "normogen-backend") generated 2 warnings
|
||||
error: could not compile `normogen-backend` (bin "normogen-backend") due to 32 previous errors; 2 warnings emitted
|
||||
Loading…
Add table
Add a link
Reference in a new issue