entrenar/research/archive/
result.rs1use serde::{Deserialize, Serialize};
4
5use super::provider::ArchiveProvider;
6use super::DOI_REGEX;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct DepositResult {
11 pub doi: String,
13 pub record_id: String,
15 pub url: String,
17 pub provider: ArchiveProvider,
19}
20
21impl DepositResult {
22 pub fn generate_url(&self) -> String {
24 self.url.clone()
25 }
26
27 pub fn doi_url(&self) -> String {
29 format!("https://doi.org/{}", self.doi)
30 }
31}
32
33#[derive(Debug, Clone, thiserror::Error)]
35pub enum DepositError {
36 #[error("No files provided for deposit")]
37 NoFiles,
38 #[error("Authentication failed")]
39 AuthenticationFailed,
40 #[error("Invalid metadata: {0}")]
41 InvalidMetadata(String),
42 #[error("Upload failed: {0}")]
43 UploadFailed(String),
44 #[error("API error: {0}")]
45 ApiError(String),
46}
47
48pub fn validate_doi(doi: &str) -> bool {
50 DOI_REGEX.is_match(doi)
51}