pub struct Backend { /* private fields */ }
Expand description
Backend for IPFS.
Trait Implementations
sourceimpl Accessor for Backend
impl Accessor for Backend
sourcefn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
__arg2: OpStat
) -> Pin<Box<dyn Future<Output = Result<ObjectMetadata>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
__arg2: OpStat
) -> Pin<Box<dyn Future<Output = Result<ObjectMetadata>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
IPFS’s stat behavior highly depends on its implementation.
Based on IPFS Path Gateway Specification, response payload could be:
- UnixFS (implicit default)
- File
- Bytes representing file contents
- Directory
- Generated HTML with directory index
- When
index.html
is present, gateway can skip generating directory index and return it instead- Raw block (not this case)
- CAR (not this case)
When we HEAD a given path, we could have the following responses:
- File
:) curl -I https://ipfs.io/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ/normal_file
HTTP/1.1 200 Connection established
HTTP/2 200
server: openresty
date: Thu, 08 Sep 2022 00:48:50 GMT
content-type: application/octet-stream
content-length: 262144
access-control-allow-methods: GET
cache-control: public, max-age=29030400, immutable
etag: "QmdP6teFTLSNVhT4W5jkhEuUBsjQ3xkp1GmRvDU6937Me1"
x-ipfs-gateway-host: ipfs-bank11-fr2
x-ipfs-path: /ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ/normal_file
x-ipfs-roots: QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ,QmdP6teFTLSNVhT4W5jkhEuUBsjQ3xkp1GmRvDU6937Me1
x-ipfs-pop: ipfs-bank11-fr2
timing-allow-origin: *
x-ipfs-datasize: 262144
access-control-allow-origin: *
access-control-allow-methods: GET, POST, OPTIONS
access-control-allow-headers: X-Requested-With, Range, Content-Range, X-Chunked-Output, X-Stream-Output
access-control-expose-headers: Content-Range, X-Chunked-Output, X-Stream-Output
x-ipfs-lb-pop: gateway-bank1-fr2
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-proxy-cache: MISS
accept-ranges: bytes
- Dir with generated index
:( curl -I https://ipfs.io/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ/normal_dir
HTTP/1.1 200 Connection established
HTTP/2 200
server: openresty
date: Wed, 07 Sep 2022 08:46:13 GMT
content-type: text/html
vary: Accept-Encoding
access-control-allow-methods: GET
etag: "DirIndex-2b567f6r5vvdg_CID-QmY44DyCDymRN1Qy7sGbupz1ysMkXTWomAQku5vBg7fRQW"
x-ipfs-gateway-host: ipfs-bank6-sg1
x-ipfs-path: /ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ/normal_dir
x-ipfs-roots: QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ,QmY44DyCDymRN1Qy7sGbupz1ysMkXTWomAQku5vBg7fRQW
x-ipfs-pop: ipfs-bank6-sg1
timing-allow-origin: *
access-control-allow-origin: *
access-control-allow-methods: GET, POST, OPTIONS
access-control-allow-headers: X-Requested-With, Range, Content-Range, X-Chunked-Output, X-Stream-Output
access-control-expose-headers: Content-Range, X-Chunked-Output, X-Stream-Output
x-ipfs-lb-pop: gateway-bank3-sg1
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-proxy-cache: MISS
- Dir with index.html
:) curl -I http://127.0.0.1:8080/ipfs/QmVturFGV3z4WsP7cRV8Ci4avCdGWYXk2qBKvtAwFUp5Az
HTTP/1.1 302 Found
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Headers: Range
Access-Control-Allow-Headers: User-Agent
Access-Control-Allow-Headers: X-Requested-With
Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Length
Access-Control-Expose-Headers: Content-Range
Access-Control-Expose-Headers: X-Chunked-Output
Access-Control-Expose-Headers: X-Ipfs-Path
Access-Control-Expose-Headers: X-Ipfs-Roots
Access-Control-Expose-Headers: X-Stream-Output
Content-Type: text/html; charset=utf-8
Location: /ipfs/QmVturFGV3z4WsP7cRV8Ci4avCdGWYXk2qBKvtAwFUp5Az/
X-Ipfs-Path: /ipfs/QmVturFGV3z4WsP7cRV8Ci4avCdGWYXk2qBKvtAwFUp5Az
X-Ipfs-Roots: QmVturFGV3z4WsP7cRV8Ci4avCdGWYXk2qBKvtAwFUp5Az
Date: Thu, 08 Sep 2022 00:52:29 GMT
In conclusion:
- HTTP Status Code == 302 => directory
- HTTP Status Code == 200 && ETag starts with
"DirIndex
=> directory - HTTP Status Code == 200 && ETag not starts with
"DirIndex
=> file
sourcefn metadata(&self) -> AccessorMetadata
fn metadata(&self) -> AccessorMetadata
Invoke the
metadata
operation to get metadata of accessor.sourcefn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpRead
) -> Pin<Box<dyn Future<Output = Result<BytesReader>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpRead
) -> Pin<Box<dyn Future<Output = Result<BytesReader>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
read
operation on the specified path, returns a
BytesReader
if operate successful. Read moresourcefn list<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
__arg2: OpList
) -> Pin<Box<dyn Future<Output = Result<ObjectStreamer>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
__arg2: OpList
) -> Pin<Box<dyn Future<Output = Result<ObjectStreamer>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
list
operation on the specified path. Read moresourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCreate
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCreate
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
create
operation on the specified path Read moresourcefn write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpWrite,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpWrite,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
write
operation on the specified path, returns a
written size if operate successful. Read moresourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpDelete
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpDelete
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
delete
operation on the specified path. Read moresourcefn presign(&self, path: &str, args: OpPresign) -> Result<PresignedRequest>
fn presign(&self, path: &str, args: OpPresign) -> Result<PresignedRequest>
Invoke the
presign
operation on the specified path. Read moresourcefn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCreateMultipart
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
create_multipart
operation on the specified path. Read moresourcefn write_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpWriteMultipart,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<ObjectPart>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn write_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpWriteMultipart,
r: BytesReader
) -> Pin<Box<dyn Future<Output = Result<ObjectPart>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
write_multipart
operation on the specified path. Read moresourcefn complete_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn complete_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpCompleteMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
complete_multipart
operation on the specified path. Read moresourcefn abort_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn abort_multipart<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
args: OpAbortMultipart
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Invoke the
abort_multipart
operation on the specified path. Read moresourcefn blocking_create(&self, path: &str, args: OpCreate) -> Result<()>
fn blocking_create(&self, path: &str, args: OpCreate) -> Result<()>
Invoke the
blocking_create
operation on the specified path. Read moresourcefn blocking_read(&self, path: &str, args: OpRead) -> Result<BlockingBytesReader>
fn blocking_read(&self, path: &str, args: OpRead) -> Result<BlockingBytesReader>
Invoke the
blocking_read
operation on the specified path. Read moresourcefn blocking_write(
&self,
path: &str,
args: OpWrite,
r: BlockingBytesReader
) -> Result<u64>
fn blocking_write(
&self,
path: &str,
args: OpWrite,
r: BlockingBytesReader
) -> Result<u64>
Invoke the
blocking_write
operation on the specified path. Read moresourcefn blocking_stat(&self, path: &str, args: OpStat) -> Result<ObjectMetadata>
fn blocking_stat(&self, path: &str, args: OpStat) -> Result<ObjectMetadata>
Invoke the
blocking_stat
operation on the specified path. Read moresourcefn blocking_delete(&self, path: &str, args: OpDelete) -> Result<()>
fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<()>
Invoke the
blocking_delete
operation on the specified path. Read moresourcefn blocking_list(&self, path: &str, args: OpList) -> Result<ObjectIterator>
fn blocking_list(&self, path: &str, args: OpList) -> Result<ObjectIterator>
Invoke the
blocking_list
operation on the specified path. Read moreAuto Trait Implementations
impl !RefUnwindSafe for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl !UnwindSafe for Backend
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more