use std::sync::Arc;
use crate::format::FormatKind;
use crate::io::{AsyncInputProvider, AsyncOutputTarget};
use super::FileExistsPolicy;
#[derive(Debug, Clone)]
pub struct AsyncInputSpec {
pub raw: String,
pub provider: Arc<dyn AsyncInputProvider>,
pub explicit_format: Option<FormatKind>,
pub format_candidates: Vec<FormatKind>,
}
impl AsyncInputSpec {
pub fn new(raw: impl Into<String>, provider: Arc<dyn AsyncInputProvider>) -> Self {
Self {
raw: raw.into(),
provider,
explicit_format: None,
format_candidates: Vec::new(),
}
}
pub fn with_format(mut self, format: FormatKind) -> Self {
self.explicit_format = Some(format);
self
}
pub fn with_candidates(mut self, candidates: Vec<FormatKind>) -> Self {
self.format_candidates = candidates;
self
}
}
#[derive(Debug, Clone)]
pub struct AsyncOutputSpec {
pub raw: String,
pub target: Arc<dyn AsyncOutputTarget>,
pub explicit_format: Option<FormatKind>,
pub format_candidates: Vec<FormatKind>,
pub file_exists_policy: FileExistsPolicy,
}
impl AsyncOutputSpec {
pub fn new(raw: impl Into<String>, target: Arc<dyn AsyncOutputTarget>) -> Self {
Self {
raw: raw.into(),
target,
explicit_format: None,
format_candidates: Vec::new(),
file_exists_policy: FileExistsPolicy::default(),
}
}
pub fn with_format(mut self, format: FormatKind) -> Self {
self.explicit_format = Some(format);
self
}
pub fn with_candidates(mut self, candidates: Vec<FormatKind>) -> Self {
self.format_candidates = candidates;
self
}
pub fn with_file_exists_policy(mut self, policy: FileExistsPolicy) -> Self {
self.file_exists_policy = policy;
self
}
}