Skip to content

Commit

Permalink
fix: Add #[non_exhaustive] to pub structs which may be extended in fu…
Browse files Browse the repository at this point in the history
…ture (#293)
  • Loading branch information
aawsome authored Oct 1, 2024
1 parent afaf707 commit 6d33577
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/backend/src/choose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use clap::ValueHint;
#[derive(Clone, Default, Debug, serde::Deserialize, serde::Serialize, Setters)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
#[setters(into, strip_option)]
#[non_exhaustive]
pub struct BackendOptions {
/// Repository to use
#[cfg_attr(
Expand Down
4 changes: 4 additions & 0 deletions crates/backend/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use thiserror::Error;

/// [`BackendAccessErrorKind`] describes the errors that can be returned by the various Backends
#[derive(Error, Debug, Display)]
#[non_exhaustive]
pub enum BackendAccessErrorKind {
/// backend {0:?} is not supported!
BackendNotSupported(String),
Expand Down Expand Up @@ -38,6 +39,7 @@ pub enum BackendAccessErrorKind {

/// [`RcloneErrorKind`] describes the errors that can be returned by a backend provider
#[derive(Error, Debug, Display)]
#[non_exhaustive]
pub enum RcloneErrorKind {
/// 'rclone version' doesn't give any output
NoOutputForRcloneVersion,
Expand All @@ -61,6 +63,7 @@ pub enum RcloneErrorKind {

/// [`RestErrorKind`] describes the errors that can be returned while dealing with the REST API
#[derive(Error, Debug, Display)]
#[non_exhaustive]
pub enum RestErrorKind {
/// value `{0:?}` not supported for option retry!
NotSupportedForRetry(String),
Expand All @@ -83,6 +86,7 @@ pub enum RestErrorKind {

/// [`LocalBackendErrorKind`] describes the errors that can be returned by an action on the filesystem in Backends
#[derive(Error, Debug, Display)]
#[non_exhaustive]
pub enum LocalBackendErrorKind {
/// directory creation failed: `{0:?}`
DirectoryCreationFailed(#[from] std::io::Error),
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/backend/ignore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct LocalSource {
#[derive(serde::Deserialize, serde::Serialize, Default, Clone, Copy, Debug, Setters)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
#[setters(into)]
#[non_exhaustive]
/// [`LocalSourceSaveOptions`] describes how entries from a local source will be saved in the repository.
pub struct LocalSourceSaveOptions {
/// Save access time for files and directories
Expand All @@ -65,6 +66,7 @@ pub struct LocalSourceSaveOptions {
#[derive(serde::Deserialize, serde::Serialize, Default, Clone, Debug, Setters)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
#[setters(into)]
#[non_exhaustive]
/// [`LocalSourceFilterOptions`] allow to filter a local source by various criteria.
pub struct LocalSourceFilterOptions {
/// Glob pattern to exclude/include (can be specified multiple times)
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/blob/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ impl IntoIterator for Tree {
#[derive(Derivative, Clone, Debug, Setters)]
#[derivative(Default)]
#[setters(into)]
#[non_exhaustive]
/// Options for listing the `Nodes` of a `Tree`
pub struct TreeStreamerOptions {
/// Glob pattern to exclude/include (can be specified multiple times)
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::{
};

#[derive(Clone, Copy, Debug, Default)]
#[non_exhaustive]
/// Options to specify which subset of packs will be read
pub enum ReadSubsetOption {
#[default]
Expand Down Expand Up @@ -119,6 +120,7 @@ impl FromStr for ReadSubsetOption {
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Clone, Copy, Debug, Default, Setters)]
#[setters(into)]
#[non_exhaustive]
/// Options for the `check` command
pub struct CheckOptions {
/// Don't verify the data saved in the cache
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub(crate) fn save_config<P, S>(
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Debug, Clone, Copy, Default, Setters)]
#[setters(into)]
#[non_exhaustive]
/// Options for the `config` command, used to set repository-wide options
pub struct ConfigOptions {
/// Set compression level. Allowed levels are 1 to 22 and -1 to -7, see <https://facebook.github.io/zstd/>.
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/commands/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Debug, Clone, Default, Setters)]
#[setters(into)]
#[non_exhaustive]
/// Options for the `key` command. These are used when creating a new key.
pub struct KeyOptions {
/// Set 'hostname' in public key information
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/commands/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub(super) mod constants {
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Debug, Clone, Setters)]
#[setters(into)]
#[non_exhaustive]
/// Options for the `prune` command
pub struct PruneOptions {
/// Define maximum data to repack in % of reposize or as size (e.g. '5b', '2 kB', '3M', '4TiB') or 'unlimited'
Expand Down Expand Up @@ -248,6 +249,7 @@ impl PruneOptions {

/// Enum to specify a size limit
#[derive(Clone, Copy, Debug)]
#[non_exhaustive]
pub enum LimitOption {
/// Size in bytes
Size(ByteSize),
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/commands/repair/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Debug, Setters)]
#[setters(into)]
#[non_exhaustive]
/// Options for the `repair snapshots` command
pub struct RepairSnapshotsOptions {
/// Also remove defect snapshots
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/commands/repoinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
};

#[derive(Default, Clone, Debug, Serialize, Deserialize)]
#[non_exhaustive]
/// Index information from `repoinfo`
pub struct IndexInfos {
/// Infos about blobs
Expand All @@ -25,6 +26,7 @@ pub struct IndexInfos {
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[non_exhaustive]
/// Information about blobs within `repoinfo`
pub struct BlobInfo {
/// Blob type
Expand Down Expand Up @@ -57,6 +59,7 @@ impl BlobInfo {

#[skip_serializing_none]
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[non_exhaustive]
/// Information about packs within `repoinfo`
pub struct PackInfo {
/// Packs of the given blob type
Expand Down Expand Up @@ -155,6 +158,7 @@ pub(crate) fn collect_index_infos<P: ProgressBars, S: Open>(

#[skip_serializing_none]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
#[non_exhaustive]
/// Information about repository files
pub struct RepoFileInfos {
/// Repository files
Expand All @@ -164,6 +168,7 @@ pub struct RepoFileInfos {
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[non_exhaustive]
/// Information about a repository files of a given [`FileType`]
pub struct RepoFileInfo {
/// The type of the files
Expand Down
3 changes: 3 additions & 0 deletions crates/core/src/commands/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Filenames = Vec<PathBuf>;
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Debug, Copy, Clone, Default, Setters)]
#[setters(into)]
#[non_exhaustive]
/// Options for the `restore` command
pub struct RestoreOptions {
/// Remove all files/dirs in destination which are not contained in snapshot.
Expand All @@ -68,6 +69,7 @@ pub struct RestoreOptions {
}

#[derive(Default, Debug, Clone, Copy)]
#[non_exhaustive]
/// Statistics for files or directories
pub struct FileDirStats {
/// Number of files or directories to restore
Expand All @@ -83,6 +85,7 @@ pub struct FileDirStats {
}

#[derive(Default, Debug, Clone, Copy)]
#[non_exhaustive]
/// Restore statistics
pub struct RestoreStats {
/// file statistics
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mod constants {
#[derive(Clone, Default, Debug, serde::Deserialize, serde::Serialize, Setters)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
#[setters(into, strip_option)]
#[non_exhaustive]
pub struct RepositoryOptions {
/// Password of the repository
///
Expand Down

0 comments on commit 6d33577

Please sign in to comment.