use crate::Operation::Write;
#[cfg(feature = "r2")]
use crate::R2Path;
use crate::Reason::UnknownFileSystem;
use crate::{Error, FilePath, Headers, LocalPath};
impl FilePath {
#[cfg_attr(not(feature = "r2"), allow(unused_variables))]
pub fn overwrite_with_headers<D>(&self, data: D, headers: &Headers) -> Result<(), Error>
where
D: AsRef<[u8]>,
{
if let Some(path) = LocalPath::new(self.path()) {
return path.overwrite(data.as_ref());
}
#[cfg(feature = "r2")]
if let Some(path) = R2Path::new(self.path()) {
return path.overwrite_with_headers(data, headers);
}
Err(Error::new(self.clone(), Write, UnknownFileSystem))
}
}