aboutsummaryrefslogtreecommitdiff
path: root/aero-proto/src/dav/resource.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-04-23 15:20:29 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-04-23 15:20:29 +0200
commit50ce8621c2eaf91c46be0a2a9c2b82b19e66880b (patch)
treea2a90b18d23b11e92818a0bdced912e33b1d576d /aero-proto/src/dav/resource.rs
parent4594e068dbba3d3d704728449fc6ccaaadaa82f1 (diff)
downloadaerogramme-50ce8621c2eaf91c46be0a2a9c2b82b19e66880b.tar.gz
aerogramme-50ce8621c2eaf91c46be0a2a9c2b82b19e66880b.zip
GET implementation
Diffstat (limited to 'aero-proto/src/dav/resource.rs')
-rw-r--r--aero-proto/src/dav/resource.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/aero-proto/src/dav/resource.rs b/aero-proto/src/dav/resource.rs
index 02a246e..bd377fb 100644
--- a/aero-proto/src/dav/resource.rs
+++ b/aero-proto/src/dav/resource.rs
@@ -64,6 +64,12 @@ impl DavNode for RootNode {
fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> {
todo!()
}
+
+ fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>> {
+ async {
+ futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
+ }.boxed()
+ }
}
#[derive(Clone)]
@@ -127,6 +133,12 @@ impl DavNode for HomeNode {
fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> {
todo!()
}
+
+ fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>> {
+ async {
+ futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
+ }.boxed()
+ }
}
#[derive(Clone)]
@@ -200,6 +212,12 @@ impl DavNode for CalendarListNode {
fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> {
todo!()
}
+
+ fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>> {
+ async {
+ futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
+ }.boxed()
+ }
}
#[derive(Clone)]
@@ -290,6 +308,12 @@ impl DavNode for CalendarNode {
fn put<'a>(&'a self, _policy: PutPolicy, stream: Content<'a>) -> BoxFuture<'a, Result<Etag>> {
todo!()
}
+
+ fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>> {
+ async {
+ futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
+ }.boxed()
+ }
}
const FAKE_ICS: &str = r#"BEGIN:VCALENDAR
@@ -386,7 +410,8 @@ impl DavNode for EventNode {
_ => ()
};
- //@FIXME for now, our storage interface does not allow for streaming
+ //@FIXME for now, our storage interface does not allow streaming,
+ // so we load everything in memory
let mut evt = Vec::new();
let mut reader = stream.into_async_read();
reader.read_to_end(&mut evt).await.unwrap();
@@ -394,6 +419,19 @@ impl DavNode for EventNode {
Ok(entry.2)
}.boxed()
}
+
+ fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>> {
+ async {
+ //@FIXME for now, our storage interface does not allow streaming,
+ // so we load everything in memory
+ let content = self.col.get(self.blob_id).await.or(Err(std::io::Error::from(std::io::ErrorKind::Interrupted)));
+ let r = async {
+ Ok(hyper::body::Bytes::from(content?))
+ };
+ //tokio::pin!(r);
+ futures::stream::once(Box::pin(r)).boxed()
+ }.boxed()
+ }
}
#[derive(Clone)]
@@ -440,4 +478,10 @@ impl DavNode for CreateEventNode {
Ok(entry.2)
}.boxed()
}
+
+ fn content<'a>(&'a self) -> BoxFuture<'a, Content<'static>> {
+ async {
+ futures::stream::once(futures::future::err(std::io::Error::from(std::io::ErrorKind::Unsupported))).boxed()
+ }.boxed()
+ }
}