entrenar/research/archive/
config.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ZenodoConfig {
8 pub token: String,
10 pub sandbox: bool,
12 pub community: Option<String>,
14}
15
16impl ZenodoConfig {
17 pub fn new(token: impl Into<String>) -> Self {
19 Self { token: token.into(), sandbox: false, community: None }
20 }
21
22 pub fn with_sandbox(mut self, sandbox: bool) -> Self {
24 self.sandbox = sandbox;
25 self
26 }
27
28 pub fn with_community(mut self, community: impl Into<String>) -> Self {
30 self.community = Some(community.into());
31 self
32 }
33
34 pub fn base_url(&self) -> &'static str {
36 if self.sandbox {
37 "https://sandbox.zenodo.org"
38 } else {
39 "https://zenodo.org"
40 }
41 }
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct FigshareConfig {
47 pub token: String,
49 pub project_id: Option<u64>,
51}
52
53impl FigshareConfig {
54 pub fn new(token: impl Into<String>) -> Self {
56 Self { token: token.into(), project_id: None }
57 }
58
59 pub fn with_project(mut self, project_id: u64) -> Self {
61 self.project_id = Some(project_id);
62 self
63 }
64}