Skip to content

Commit

Permalink
chore(deps): remove deprecated lazy_static
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Zak <[email protected]>
  • Loading branch information
rjzak committed Feb 1, 2025
1 parent a7c68ed commit 0096f7c
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 98 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ unsafe-serialization = []
bytes = { workspace = true, default-features = false }
chrono = { workspace = true, features = ["clock", "serde"], default-features = false }
clap = { workspace = true, features = ["derive", "env", "std"], default-features = false, optional = true }
lazy_static = { workspace = true, default-features = false }
reqwest = { workspace = true, features = ["gzip", "multipart", "stream"], default-features = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["alloc"], default-features = false }
Expand Down Expand Up @@ -61,7 +60,6 @@ bytes = { version = "1.9", default-features = false }
chrono = { version = "0.4", default-features = false }
clap = { version = "4.5", default-features = false }
hex = { version = "0.4.3", default-features = false }
lazy_static = { version = "1.5.0", default-features = false }
reqwest = { version = "0.12", default-features = true }
rstest = { version = "0.24.0", default-features = false }
serde = { version = "1.0", default-features = false }
Expand Down
186 changes: 97 additions & 89 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,104 +1,112 @@
use super::VirusTotalError;

use lazy_static::lazy_static;
use std::sync::LazyLock;

// See: https://virustotal.readme.io/reference/errors

lazy_static! {
/// The API request is invalid or malformed.
pub static ref BAD_REQUEST_ERROR: VirusTotalError = VirusTotalError {
code: "BadRequestError".into(),
message: "The API request is invalid or malformed. The message usually provides details about why the request is not valid.".into(),
};

/// Some of the provided arguments are incorrect.
pub static ref INVALID_ARGUMENT_ERROR: VirusTotalError = VirusTotalError {
code: "InvalidArgumentError".into(),
message: "Some of the provided arguments are incorrect.".into(),
};

/// The resource is not available yet, but will become available later.
pub static ref NOT_AVAILABLE_YET: VirusTotalError = VirusTotalError {
code: "NotAvailableYet".into(),
message: "The resource is not available yet, but will become available later.".into(),
};

/// Content search query is not selective enough.
pub static ref UNSELECTOVE_CONTENT_QUERY_ERROR: VirusTotalError = VirusTotalError {
/// The API request is invalid or malformed.
pub static BAD_REQUEST_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| {
VirusTotalError {
code: "BadRequestError".into(),
message: "The API request is invalid or malformed. The message usually provides details about why the request is not valid.".into(),
}
});

/// Some of the provided arguments are incorrect.
pub static INVALID_ARGUMENT_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "InvalidArgumentError".into(),
message: "Some of the provided arguments are incorrect.".into(),
});

/// The resource is not available yet, but will become available later.
pub static NOT_AVAILABLE_YET: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "NotAvailableYet".into(),
message: "The resource is not available yet, but will become available later.".into(),
});

/// Content search query is not selective enough.
pub static UNSELECTOVE_CONTENT_QUERY_ERROR: LazyLock<VirusTotalError> =
LazyLock::new(|| VirusTotalError {
code: "UnselectiveContentQueryError".into(),
message: "Content search query is not selective enough.".into(),
};
});

/// Unsupported content search query.
pub static ref UNSUPPORTED_CONTENT_QUERY_ERROR: VirusTotalError = VirusTotalError {
/// Unsupported content search query.
pub static UNSUPPORTED_CONTENT_QUERY_ERROR: LazyLock<VirusTotalError> =
LazyLock::new(|| VirusTotalError {
code: "UnsupportedContentQueryError".into(),
message: "Unsupported content search query.".into(),
};
});

/// The operation requires an authenticated user. Verify that you have provided your API key.
pub static ref AUTHENTICATION_REQUIRED_ERROR: VirusTotalError = VirusTotalError {
/// The operation requires an authenticated user. Verify that you have provided your API key.
pub static AUTHENTICATION_REQUIRED_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| {
VirusTotalError {
code: "AuthenticationRequiredError".into(),
message: "The operation requires an authenticated user. Verify that you have provided your API key.".into(),
};

/// "The user account is not active. Make sure you properly activated your account by following the link sent to your email.
pub static ref USER_NOT_ACTIVE_ERROR: VirusTotalError = VirusTotalError {
code: "UserNotActiveError".into(),
message: "The user account is not active. Make sure you properly activated your account by following the link sent to your email.".into(),
};

/// The provided API key is incorrect.
pub static ref WRONG_CREDENTIALS_ERROR: VirusTotalError = VirusTotalError {
code: "WrongCredentialsError".into(),
message: "The provided API key is incorrect.".into(),
};

/// You are not allowed to perform the requested operation.
pub static ref FORBIDDEN_ERROR: VirusTotalError = VirusTotalError {
code: "ForbiddenError".into(),
message: "You are not allowed to perform the requested operation.".into(),
};

/// The requested resource was not found.
pub static ref NOT_FOUND_ERROR: VirusTotalError = VirusTotalError {
code: "NotFoundError".into(),
message: "The requested resource was not found.".into(),
};

/// The resource already exists.
pub static ref ALREADY_EXISTS_ERROR: VirusTotalError = VirusTotalError {
code: "AlreadyExistsError".into(),
message: "The resource already exists.".into(),
};

/// The request depended on another request and that request failed.
pub static ref FAILED_DEPENDENCY_ERROR: VirusTotalError = VirusTotalError {
code: "FailedDependencyError".into(),
message: "The request depended on another request and that request failed.".into(),
};

/// You have exceeded one of your quotas (minute, daily or monthly).
pub static ref QUOTA_EXCEEDED_ERROR: VirusTotalError = VirusTotalError {
code: "QuotaExceededError".into(),
message: "You have exceeded one of your quotas (minute, daily or monthly). Daily quotas are reset every day at 00:00 UTC.
}
});

/// The user account is not active. Make sure you properly activated your account by following the link sent to your email.
pub static USER_NOT_ACTIVE_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| {
VirusTotalError {
code: "UserNotActiveError".into(),
message: "The user account is not active. Make sure you properly activated your account by following the link sent to your email.".into(),
}
});

/// The provided API key is incorrect.
pub static WRONG_CREDENTIALS_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "WrongCredentialsError".into(),
message: "The provided API key is incorrect.".into(),
});

/// You are not allowed to perform the requested operation.
pub static FORBIDDEN_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "ForbiddenError".into(),
message: "You are not allowed to perform the requested operation.".into(),
});

/// The requested resource was not found.
pub static NOT_FOUND_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "NotFoundError".into(),
message: "The requested resource was not found.".into(),
});

/// The resource already exists.
pub static ALREADY_EXISTS_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "AlreadyExistsError".into(),
message: "The resource already exists.".into(),
});

/// The request depended on another request and that request failed.
pub static FAILED_DEPENDENCY_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "FailedDependencyError".into(),
message: "The request depended on another request and that request failed.".into(),
});

/// You have exceeded one of your quotas (minute, daily or monthly).
pub static QUOTA_EXCEEDED_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| {
VirusTotalError {
code: "QuotaExceededError".into(),
message: "You have exceeded one of your quotas (minute, daily or monthly). Daily quotas are reset every day at 00:00 UTC.
You may have run out of disk space and/or number of files on your VirusTotal Monitor account.".into(),
};

/// Too many requests.
pub static ref TOO_MANY_REQUESTS_ERROR: VirusTotalError = VirusTotalError {
code: "TooManyRequestsError".into(),
message: "Too many requests.".into(),
};

/// Transient server error. Retry might work.
pub static ref TRANSIENT_ERROR: VirusTotalError = VirusTotalError {
code: "TransientError".into(),
message: "Transient server error. Retry might work.".into(),
};

/// The operation took too long to complete.
pub static ref DEADLINE_EXCEEDED_ERROR: VirusTotalError = VirusTotalError {
code: "DeadlineExceededError".into(),
message: "The operation took too long to complete.".into(),
};
}
});

/// Too many requests.
pub static TOO_MANY_REQUESTS_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "TooManyRequestsError".into(),
message: "Too many requests.".into(),
});

/// Transient server error. Retry might work.
pub static TRANSIENT_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "TransientError".into(),
message: "Transient server error. Retry might work.".into(),
});

/// The operation took too long to complete.
pub static DEADLINE_EXCEEDED_ERROR: LazyLock<VirusTotalError> = LazyLock::new(|| VirusTotalError {
code: "DeadlineExceededError".into(),
message: "The operation took too long to complete.".into(),
});

0 comments on commit 0096f7c

Please sign in to comment.