Skip to content

Commit

Permalink
Merge pull request #812 from uzyn/derive-debug
Browse files Browse the repository at this point in the history
Implements fmt::Debug to pub structs
  • Loading branch information
kaplanelad authored Oct 13, 2024
2 parents 387d094 + d8d656f commit 36f8242
Show file tree
Hide file tree
Showing 32 changed files with 47 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/auth/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct UserClaims {
///
/// auth::jwt::JWT::new("PqRwLF2rhHe8J22oBeHy");
/// ```
#[derive(Debug)]
pub struct JWT {
secret: String,
algorithm: Algorithm,
Expand Down
1 change: 1 addition & 0 deletions src/bgworker/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ pub async fn ping(pool: &PgPool) -> Result<()> {
Ok(())
}

#[derive(Debug)]
pub struct RunOpts {
pub num_workers: u32,
pub poll_interval_sec: u32,
Expand Down
1 change: 1 addition & 0 deletions src/bgworker/skq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bb8::Pool;
use sidekiq::{Processor, ProcessorConfig, RedisConnectionManager};
pub type RedisPool = Pool<RedisConnectionManager>;

#[derive(Debug)]
pub struct SidekiqBackgroundWorker<W, A> {
pub inner: W, // Now we store the worker with its actual type instead of a trait object
_phantom: PhantomData<A>,
Expand Down
3 changes: 3 additions & 0 deletions src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::{
};

/// Represents the application startup mode.
#[derive(Debug)]
pub enum StartMode {
/// Run the application as a server only. when running web server only,
/// workers job will not handle.
Expand All @@ -36,6 +37,7 @@ pub enum StartMode {
/// Pulling job worker and execute them
WorkerOnly,
}

pub struct BootResult {
/// Application Context
pub app_context: AppContext,
Expand All @@ -46,6 +48,7 @@ pub struct BootResult {
}

/// Configuration structure for serving an application.
#[derive(Debug)]
pub struct ServeParams {
/// The port number on which the server will listen for incoming
/// connections.
Expand Down
1 change: 1 addition & 0 deletions src/cache/drivers/inmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub fn new() -> Box<dyn CacheDriver> {
}

/// Represents the in-memory cache driver.
#[derive(Debug)]
pub struct Inmem {
cache: Cache<String, String>,
}
Expand Down
1 change: 1 addition & 0 deletions src/cache/drivers/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::CacheDriver;
use crate::cache::{CacheError, CacheResult};

/// Represents the in-memory cache driver.
#[derive(Debug)]
pub struct Null {}

/// Creates a new null cache instance
Expand Down
1 change: 1 addition & 0 deletions src/controller/app_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct AppRoutes {
channels: Option<AppChannels>,
}

#[derive(Debug)]
pub struct ListRoutes {
pub uri: String,
pub actions: Vec<axum::http::Method>,
Expand Down
1 change: 1 addition & 0 deletions src/controller/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ where
html(&views::template(template, data)?)
}

#[derive(Debug)]
pub struct RenderBuilder {
response: Builder,
}
Expand Down
4 changes: 2 additions & 2 deletions src/controller/middleware/_archive/content_etag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use hyper::header::{ETAG, IF_NONE_MATCH};
use sha2::{Digest, Sha256};
use tower::{Layer, Service}; // Corrected import

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct EtagLayer;

impl EtagLayer {
Expand All @@ -30,7 +30,7 @@ impl<S> Layer<S> for EtagLayer {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct EtagMiddleware<S> {
inner: S,
}
Expand Down
1 change: 1 addition & 0 deletions src/controller/middleware/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use tower_http::services::ServeFile;

use crate::{app::AppContext, controller::middleware::MiddlewareLayer, Result};

#[derive(Debug)]
pub struct StatusCodeWrapper(pub StatusCode);

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/controller/middleware/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Config {
}

/// [`Middleware`] struct responsible for logging HTTP requests.
#[derive(Serialize)]
#[derive(Serialize, Debug)]
pub struct Middleware {
config: Config,
environment: Environment,
Expand Down
1 change: 1 addition & 0 deletions src/controller/middleware/powered_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ lazy_static::lazy_static! {
}

/// [`Middleware`] struct responsible for managing the identifier value for the `X-Powered-By` header.
#[derive(Debug)]
pub struct Middleware {
ident: Option<HeaderValue>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/controller/middleware/remote_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl fmt::Display for RemoteIP {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
struct RemoteIPLayer {
trusted_proxies: Option<Vec<IpNetwork>>,
}
Expand Down Expand Up @@ -252,7 +252,7 @@ impl<S> Layer<S> for RemoteIPLayer {
}

/// Remote IP Detection Middleware
#[derive(Clone)]
#[derive(Clone, Debug)]
#[must_use]
pub struct RemoteIPMiddleware<S> {
inner: S,
Expand Down
4 changes: 2 additions & 2 deletions src/controller/middleware/secure_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl SecureHeader {

/// The [`SecureHeaders`] layer which wraps around the service and injects
/// security headers
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct SecureHeaders {
headers: Vec<(HeaderName, HeaderValue)>,
}
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<S> Layer<S> for SecureHeaders {
}

/// The secure headers middleware
#[derive(Clone)]
#[derive(Clone, Debug)]
#[must_use]
pub struct SecureHeadersMiddleware<S> {
inner: S,
Expand Down
4 changes: 2 additions & 2 deletions src/controller/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use tower::{Layer, Service};

use super::describe;
use crate::app::AppContext;
#[derive(Clone, Default)]
#[derive(Clone, Default, Debug)]
pub struct Routes {
pub prefix: Option<String>,
pub handlers: Vec<Handler>,
// pub version: Option<String>,
}

#[derive(Clone, Default)]
#[derive(Clone, Default, Debug)]
pub struct Handler {
pub uri: String,
pub method: axum::routing::MethodRouter<AppContext>,
Expand Down
2 changes: 1 addition & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lazy_static! {
pub static ref EXTRACT_DB_NAME: Regex = Regex::new(r"/([^/]+)$").unwrap();
}

#[derive(Default, Clone)]
#[derive(Default, Clone, Debug)]
pub struct MultiDb {
pub db: HashMap<String, DatabaseConnection>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const QUEUE_CONN_FAILED: &str = "queue connection: failed";
const QUEUE_NOT_CONFIGURED: &str = "queue not configured?";

/// Represents different resources that can be checked.
#[derive(PartialOrd, PartialEq, Eq, Ord)]
#[derive(PartialOrd, PartialEq, Eq, Ord, Debug)]
pub enum Resource {
SeaOrmCLI,
Database,
Expand Down
1 change: 1 addition & 0 deletions src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl FromStr for DeploymentKind {
}
}

#[derive(Debug)]
pub enum Component {
#[cfg(feature = "with-db")]
Model {
Expand Down
4 changes: 2 additions & 2 deletions src/mailer/email_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{config, errors::Error};

/// An enumeration representing the possible transport methods for sending
/// emails.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum EmailTransport {
/// SMTP (Simple Mail Transfer Protocol) transport.
Smtp(lettre::AsyncSmtpTransport<lettre::Tokio1Executor>),
Expand All @@ -23,7 +23,7 @@ pub enum EmailTransport {

/// A structure representing the email sender, encapsulating the chosen
/// transport method.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct EmailSender {
pub transport: EmailTransport,
}
Expand Down
2 changes: 1 addition & 1 deletion src/mailer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct Email {
}

/// The options struct for configuring the email sender.
#[derive(Default)]
#[derive(Default, Debug)]
#[allow(clippy::module_name_repetitions)]
pub struct MailerOpts {
pub from: String,
Expand Down
2 changes: 2 additions & 0 deletions src/model/query/dsl/date_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use chrono::NaiveDateTime;
use sea_orm::ColumnTrait;

use super::{with, ConditionBuilder};

#[derive(Debug)]
pub struct DateRangeBuilder<T: ColumnTrait> {
col: T,
condition_builder: ConditionBuilder,
Expand Down
1 change: 1 addition & 0 deletions src/model/query/dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod date_range;

// pub mod pagination;

#[derive(Debug)]
pub struct ConditionBuilder {
condition: Condition,
}
Expand Down
3 changes: 2 additions & 1 deletion src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl fmt::Display for Scheduler {
}

/// Representing the scheduler itself.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Scheduler {
pub jobs: HashMap<String, Job>,
binary_path: PathBuf,
Expand All @@ -119,6 +119,7 @@ pub struct Scheduler {
}

/// Specification used to filter all scheduler job with the given Spec.
#[derive(Debug)]
pub struct Spec {
pub name: Option<String>,
pub tag: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions src/storage/contents.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bytes::Bytes;

#[derive(Debug)]
pub struct Contents {
data: Bytes,
}
Expand Down
1 change: 1 addition & 0 deletions src/storage/drivers/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::{object_store_adapter::ObjectStoreAdapter, StoreDriver};
use crate::Result;

/// A set of AWS security credentials
#[derive(Debug)]
pub struct Credential {
/// `AWS_ACCESS_KEY_ID`
pub key_id: String,
Expand Down
2 changes: 2 additions & 0 deletions src/storage/drivers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub mod null;
pub mod object_store_adapter;

use super::StorageResult;

#[derive(Debug)]
pub struct UploadResponse {
pub e_tag: Option<String>,
pub version: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/storage/strategies/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use bytes::Bytes;
use crate::storage::{strategies::StorageStrategy, Storage, StorageError, StorageResult};

/// Enum representing the failure mode for the [`BackupStrategy`].
#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum FailureMode {
/// Fail if any secondary storage backend encounters an error.
BackupAll,
Expand Down
4 changes: 2 additions & 2 deletions src/storage/strategies/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bytes::Bytes;
use crate::storage::{strategies::StorageStrategy, Storage, StorageError, StorageResult};

/// Enum representing the failure mode for the [`MirrorStrategy`].
#[derive(Clone)]
#[derive(Clone, Debug)]
pub enum FailureMode {
/// Fail if any secondary storage mirror encounters an error.
MirrorAll,
Expand All @@ -36,7 +36,7 @@ pub enum FailureMode {
}

/// Represents the Mirror Strategy for storage operations.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct MirrorStrategy {
/// The primary storage backend.
pub primary: String,
Expand Down
1 change: 1 addition & 0 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl Vars {

/// Information about a task, including its name and details.
#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub struct TaskInfo {
pub name: String,
pub detail: String,
Expand Down
2 changes: 2 additions & 0 deletions src/tests_cfg/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub mod test_db {
impl ActiveModelBehavior for ActiveModel {}
}

#[derive(Debug)]
pub struct Migrator;

#[async_trait::async_trait]
Expand All @@ -79,6 +80,7 @@ impl MigratorTrait for Migrator {
}
}

#[derive(Debug)]
pub struct AppHook;
#[async_trait]
impl Hooks for AppHook {
Expand Down
4 changes: 4 additions & 0 deletions src/tests_cfg/task.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::prelude::*;

#[derive(Debug)]
pub struct Foo;

#[async_trait]
impl Task for Foo {
fn task(&self) -> TaskInfo {
Expand All @@ -15,7 +17,9 @@ impl Task for Foo {
}
}

#[derive(Debug)]
pub struct ParseArgs;

#[async_trait]
impl Task for ParseArgs {
fn task(&self) -> TaskInfo {
Expand Down
1 change: 1 addition & 0 deletions src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub fn is_valid_email(email: &str) -> Result<(), ValidationError> {
/// in the trait, we MUST use `DbErr`, so we need to "hide" a _representation_
/// of the error in `DbErr::Custom`, so that it can be unpacked later down the
/// stream, in the central error response handler.
#[derive(Debug)]
pub struct ModelValidationErrors(pub ValidationErrors);

#[cfg(feature = "with-db")]
Expand Down

0 comments on commit 36f8242

Please sign in to comment.