-
Notifications
You must be signed in to change notification settings - Fork 2
Description
WIP design document for a new code architecture
-
Rename
DandiDavtoDav -
Give
Davaregister(name: &Component, handler: Box<dyn DavHandler>, description: &str) -> Result<(), DuplicateNameError>method for registering a handler for a WebDAV hierarchy to serve under/{name}/descriptionis used as the "Type" value for the hierarchy in the root HTML view- As an alternative to boxing, the type of
handlercould instead be an enum using enum dispatch.
-
Add a
DavHandlertrait 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
pathmay be empty (i.e., when a client requests/{name}/), and soPurePathcannot 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
DandiDavstruct implementingDavHandlerfor serving resources under/dandisets/; move all code specific to/dandisets/here- This struct will implement resolution of paths under
/dandisets/, currently implemented by the currentDandiDavtype viaDavPath
- This struct will implement resolution of paths under
-
Add a
ZarrManstruct implementingDavHandlerfor serving resources under/zarrs/ -
Idea: The internal implementations of the
DavHandlertypes could traverse their hierarchies as follows:-
Locations in a handler's hierarchy are represented by an enum with variants for different depths & similar (cf.
DavPathandzarrman::ReqPath) -
The handler instantiates a location enum with the root variant and then applies each component in
pathin turn by calling aninto_child(self, name: Component) -> Result<Self, DavError>method- This method returns
Errif 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
DavHandlers don't prepend it, what would thepaths of their root collections be?None? - Give
DavResource[WithChildren]aprepend_path(&mut self, path: &PureDirPath)method for calling byDavafter delegating to a handler? - Idea: Make
name(&self) -> &'static stra method ofDavHandler, and make it theDavHandlers' responsibility to prepend the name- This will be more reasonable if enum dispatch is used instead of boxing.
- If the