mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 10:33:47 +01:00
Moves schema generation over to a test instead of as a feature. This allows us to publish the crate since we use a schemars from Git, which is not supported by crates.io.
35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
use crate::source::{pesde, traits::DependencySpecifier};
|
|
use serde::{Deserialize, Serialize};
|
|
use std::fmt::Display;
|
|
|
|
/// All possible dependency specifiers
|
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
|
#[cfg_attr(test, derive(schemars::JsonSchema))]
|
|
#[serde(untagged)]
|
|
pub enum DependencySpecifiers {
|
|
/// A pesde dependency specifier
|
|
Pesde(pesde::specifier::PesdeDependencySpecifier),
|
|
/// A Wally dependency specifier
|
|
#[cfg(feature = "wally-compat")]
|
|
Wally(crate::source::wally::specifier::WallyDependencySpecifier),
|
|
/// A Git dependency specifier
|
|
Git(crate::source::git::specifier::GitDependencySpecifier),
|
|
/// A workspace dependency specifier
|
|
Workspace(crate::source::workspace::specifier::WorkspaceDependencySpecifier),
|
|
/// A path dependency specifier
|
|
Path(crate::source::path::specifier::PathDependencySpecifier),
|
|
}
|
|
impl DependencySpecifier for DependencySpecifiers {}
|
|
|
|
impl Display for DependencySpecifiers {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
DependencySpecifiers::Pesde(specifier) => write!(f, "{specifier}"),
|
|
#[cfg(feature = "wally-compat")]
|
|
DependencySpecifiers::Wally(specifier) => write!(f, "{specifier}"),
|
|
DependencySpecifiers::Git(specifier) => write!(f, "{specifier}"),
|
|
DependencySpecifiers::Workspace(specifier) => write!(f, "{specifier}"),
|
|
DependencySpecifiers::Path(specifier) => write!(f, "{specifier}"),
|
|
}
|
|
}
|
|
}
|