Skip to content

Commit

Permalink
chore: add copy & link for DynFs
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Nov 13, 2024
1 parent 4beab41 commit 4ad41c6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
34 changes: 34 additions & 0 deletions fusio/src/dynamic/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ pub trait DynFs: MaybeSend + MaybeSync {
&'s self,
path: &'path Path,
) -> Pin<Box<dyn MaybeSendFuture<Output = Result<(), Error>> + 's>>;

fn copy<'s, 'path: 's>(
&'s self,
from: &'path Path,
to: &'path Path,
) -> Pin<Box<dyn MaybeSendFuture<Output = Result<(), Error>> + 's>>;

fn link<'s, 'path: 's>(
&'s self,
from: &'path Path,
to_fs: &'s Self,
to: &'path Path,
) -> Pin<Box<dyn MaybeSendFuture<Output = Result<(), Error>> + 's>>;
}

impl<F: Fs> DynFs for F {
Expand Down Expand Up @@ -130,6 +143,27 @@ impl<F: Fs> DynFs for F {
) -> Pin<Box<dyn MaybeSendFuture<Output = Result<(), Error>> + 's>> {
Box::pin(F::remove(self, path))
}

fn copy<'s, 'path: 's>(
&'s self,
from: &'path Path,
to: &'path Path,
) -> Pin<Box<dyn MaybeSendFuture<Output = Result<(), Error>> + 's>> {
Box::pin(F::copy(self, from, to))
}

fn link<'s, 'path: 's>(
&'s self,
from: &'path Path,
to_fs: &'s Self,
to: &'path Path,
) -> Pin<Box<dyn MaybeSendFuture<Output = Result<(), Error>> + 's>> {
Box::pin(async move {
self.link(from, to_fs, to).await?;

Ok(())
})
}
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion fusio/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{cmp, future::Future};
use futures_core::Stream;
pub use options::*;

use crate::{path::Path, Error, IoBufMut, MaybeSend, MaybeSync, Read, Write};
use crate::{path::Path, Error, MaybeSend, MaybeSync, Read, Write};

#[derive(Debug)]
pub struct FileMeta {
Expand Down
4 changes: 2 additions & 2 deletions fusio/src/impls/remotes/aws/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
},
http::{DynHttpClient, HttpClient, HttpError},
},
Error, Read,
Error,
};

pub struct AmazonS3Builder {
Expand Down Expand Up @@ -349,7 +349,7 @@ mod tests {
options::S3Options,
s3::S3File,
},
http::{tokio::TokioClient, DynHttpClient, HttpClient},
http::{tokio::TokioClient, DynHttpClient},
},
Read, Write,
};
Expand Down
2 changes: 1 addition & 1 deletion fusio/src/impls/remotes/aws/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ mod tests {
options::S3Options,
s3::S3File,
},
http::{tokio::TokioClient, DynHttpClient, HttpClient},
http::{tokio::TokioClient, DynHttpClient},
},
Read, Write,
};
Expand Down
2 changes: 1 addition & 1 deletion fusio/src/impls/remotes/aws/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{mem, pin::Pin, sync::Arc};

use bytes::{BufMut, BytesMut};
use futures_util::{stream::FuturesOrdered, StreamExt};
use http_body_util::{Empty, Full};
use http_body_util::Full;

use crate::{
dynamic::MaybeSendFuture,
Expand Down

0 comments on commit 4ad41c6

Please sign in to comment.