-
Notifications
You must be signed in to change notification settings - Fork 2
Description
WIP design document for a new code architecture
-
Rename
DandiDav
toDav
-
Give
Dav
aregister(name: &Component, handler: Box<dyn DavHandler>, description: &str) -> Result<(), DuplicateNameError>
method for registering a handler for a WebDAV hierarchy to serve under/{name}/
description
is used as the "Type" value for the hierarchy in the root HTML view- As an alternative to boxing, the type of
handler
could instead be an enum using enum dispatch.
-
Add a
DavHandler
trait with the following methods:get_resource(&self, path: Vec<Component>) -> Result<DavResource, DavError>
get_resource_with_children(&self, path: Vec<Component>) -> Result<DavResourceWithChildren, DavError>
Note that
path
may be empty (i.e., when a client requests/{name}/
), and soPurePath
cannot be used here.Note that these methods will be
async
, which may have implications for boxability of trait objects; cf. https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html. -
Add a
DandiDav
struct implementingDavHandler
for serving resources under/dandisets/
; move all code specific to/dandisets/
here- This struct will implement resolution of paths under
/dandisets/
, currently implemented by the currentDandiDav
type viaDavPath
- This struct will implement resolution of paths under
-
Add a
ZarrMan
struct implementingDavHandler
for serving resources under/zarrs/
-
Idea: The internal implementations of the
DavHandler
types could traverse their hierarchies as follows:-
Locations in a handler's hierarchy are represented by an enum with variants for different depths & similar (cf.
DavPath
andzarrman::ReqPath
) -
The handler instantiates a location enum with the root variant and then applies each component in
path
in turn by calling aninto_child(self, name: Component) -> Result<Self, DavError>
method- This method returns
Err
if it can be easily determined (sans IO) that the path so far is invalid/does not exist
- This method returns
-
Details for the final location are then retrieved based on the location enum's final state
-
-
Whose responsibility is it to prepend the
/{name}/
component to hrefs in responses?- If the
DavHandler
s don't prepend it, what would thepath
s of their root collections be?None
? - Give
DavResource[WithChildren]
aprepend_path(&mut self, path: &PureDirPath)
method for calling byDav
after delegating to a handler? - Idea: Make
name(&self) -> &'static str
a method ofDavHandler
, and make it theDavHandler
s' responsibility to prepend the name- This will be more reasonable if enum dispatch is used instead of boxing.
- If the