How to create a virtual filesystem in Rust?
<p>I am developing an application, which should mount a folder over the network. It should show up similiar to a folder mounted by SMB, only that the server does not use the SMB protocol. It is similiar to this: Server A is a HTTP server, that contains files and Client B should be able to mount those files, to be directly able to access them without downloading them first (streaming). The client should thus be able to stream files, i.e. accessing the file at arbitrary positions. Also the files stored on Server A are encoded, compressed, encrypted and packetized in a specific way, so I need to decode them (do some internal processing) before presenting them to the virtual file system. The client should have read-only access. I want the client to be available on Windows and Linux. It should look like this:</p>

<p>Client has mounted a folder and wants to access /virtualfolder/data.file at position 1248989. The data stored on the server is split in blocks of arbitrary lengths (let's say it is 1 megabyte). I then need to download the part of the file corresponding to bytes 1000000 - 1999999, decode them, cache them and then the user can access this data.</p>

<p>Of course my decoding process is done internally, I just need an API to create a virtual folder (or filesystem) on the OS, that shows up the names of the files and their sizes and lets the user access them.</p>

<p>It should look like this:
[OS] &lt;-virtual filesystem API-> [Client] &lt;-some protocol-> [Server]</p>

<p>Accessing a file should look like this:</p>

<p>[OS] I want to get the bytes 0-255 from file /vfs/somefile.tar</p>

<p>[Client] Retrieving block 0-999999 from file /vfs/somefile.tar from server. This corresponds to block B5F997084DC8687. Downloading B5F997084DC8687 and decoding it.</p>

<p>[Client] Here is /vfs/somefile.tar from 0-255.</p>

<p>[OS] I want to get the bytes 256-511 from file /vfs/somefile.tar</p>

<p>[Client] This corresponds to B5F997084DC8687. Already downloaded and cached this file. </p>

<p>[Client] Here is /vfs/somefile.tar from 256-511.</p>

<p>Pretty straightforward I assume. Is there a simple API for such things?</p>