sql_fun_core/
extensions.rs1mod config_error;
2mod extension_collection;
3mod name_version_pair;
4
5pub use self::{
6 config_error::ExtensionConfigError, extension_collection::PostgresExtensionsCollection,
7 name_version_pair::ExtensionNameVersionPair,
8};
9
10use std::fmt::Display;
11
12#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq)]
14#[serde(transparent)]
15pub struct ExtensionVersion(String);
16
17impl ExtensionVersion {
18 #[must_use]
20 pub fn new(version: &str) -> Self {
21 ExtensionVersion(version.to_string())
22 }
23}
24
25impl TryFrom<&str> for ExtensionVersion {
26 type Error = ExtensionConfigError;
27
28 fn try_from(value: &str) -> Result<Self, Self::Error> {
29 if value == "." || value == ".." || value.contains([':', '/', '\\']) {
30 ExtensionConfigError::invalid_extension_version(value)?;
31 }
32 Ok(Self(value.to_string()))
33 }
34}
35
36impl Display for ExtensionVersion {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 f.write_str(&self.0)
39 }
40}