3096a2307f
* Change mixnode, gateway, network and nym-api binary licenses to GPLv3 * Add license to cargo files * Revert model license to match crate * Add license to nym-node * Revert model license to match crate * Fix formatting --------- Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com>
30 lines
706 B
Rust
30 lines
706 B
Rust
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
use serde::{Deserialize, Deserializer};
|
|
use std::path::PathBuf;
|
|
|
|
pub(super) fn de_maybe_path<'de, D>(deserializer: D) -> Result<Option<PathBuf>, D::Error>
|
|
where
|
|
D: Deserializer<'de>,
|
|
{
|
|
let path = PathBuf::deserialize(deserializer)?;
|
|
if path.as_os_str().is_empty() {
|
|
Ok(None)
|
|
} else {
|
|
Ok(Some(path))
|
|
}
|
|
}
|
|
|
|
pub(super) fn de_maybe_string<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
|
|
where
|
|
D: Deserializer<'de>,
|
|
{
|
|
let path = String::deserialize(deserializer)?;
|
|
if path.is_empty() {
|
|
Ok(None)
|
|
} else {
|
|
Ok(Some(path))
|
|
}
|
|
}
|