Skip to main content

Handle

Trait Handle 

Source
pub trait Handle: Send + Sync {
    // Required methods
    fn read<'life0, 'async_trait>(
        &'life0 self,
        offset: u64,
        len: u32,
    ) -> Pin<Box<dyn Future<Output = SmbResult<Bytes>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn write<'life0, 'life1, 'async_trait>(
        &'life0 self,
        offset: u64,
        data: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = SmbResult<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn flush<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stat<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = SmbResult<FileInfo>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_times<'life0, 'async_trait>(
        &'life0 self,
        times: FileTimes,
    ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_attributes<'life0, 'async_trait>(
        &'life0 self,
        attributes: u32,
    ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn truncate<'life0, 'async_trait>(
        &'life0 self,
        len: u64,
    ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_dir<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pattern: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = SmbResult<Vec<DirEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn close<'async_trait>(
        self: Box<Self>,
    ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait;

    // Provided method
    fn write_owned<'life0, 'async_trait>(
        &'life0 self,
        offset: u64,
        data: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = SmbResult<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A live open file or directory handle.

One handle per CREATE. The handle is dropped when CLOSE arrives or the session goes away.

Required Methods§

Source

fn read<'life0, 'async_trait>( &'life0 self, offset: u64, len: u32, ) -> Pin<Box<dyn Future<Output = SmbResult<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read up to len bytes at offset. May return fewer.

Source

fn write<'life0, 'life1, 'async_trait>( &'life0 self, offset: u64, data: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = SmbResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write data at offset. Returns bytes written.

Source

fn flush<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Flush buffered writes. May be a no-op on backends that always flush.

Source

fn stat<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SmbResult<FileInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stat: current file info.

Source

fn set_times<'life0, 'async_trait>( &'life0 self, times: FileTimes, ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set timestamps on a file or directory. None fields leave the corresponding time alone.

Return SmbError::NotSupported for an access or write time the backend cannot store. A backend that cannot store a creation time ignores it and applies the other fields; a request with only a creation time then succeeds and changes nothing. change_time is the time of the last change: a backend whose storage moves it to the current time on every change, as POSIX ctime does, may keep doing so and not store the requested value.

LocalFsBackend sets access and write times on every host and creation time on Windows and macOS. Elsewhere it ignores the creation time. The host keeps the change time.

Source

fn set_attributes<'life0, 'async_trait>( &'life0 self, attributes: u32, ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the attributes (MS-FSCC 2.6) of a file or directory to attributes, a combination of FILE_ATTRIBUTE_READONLY (0x1), HIDDEN (0x2), SYSTEM (0x4), ARCHIVE (0x20), TEMPORARY (0x100), OFFLINE (0x1000) and NOT_CONTENT_INDEXED (0x2000). Flags left out are cleared. The protocol layer calls this only when the request differs from the attributes Handle::stat reports.

Return SmbError::NotSupported if a flag cannot be stored.

LocalFsBackend stores READONLY on files: on Unix as the absence of write permission bits, on Windows as the host attribute. It accepts ARCHIVE without storing it and never reports it. Every other flag, and READONLY on a directory, returns NotSupported.

Source

fn truncate<'life0, 'async_trait>( &'life0 self, len: u64, ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Truncate (or extend) to len bytes. For directories: the protocol layer rejects this before reaching the backend.

Source

fn list_dir<'life0, 'life1, 'async_trait>( &'life0 self, pattern: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = SmbResult<Vec<DirEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List directory entries matching the optional pattern. The pattern uses the wildcards of MS-FSA 2.1.4.4: * and ?, and the DOS forms < (DOS_STAR), > (DOS_QM) and " (DOS_DOT). QUERY_DIRECTORY returns the result as is, so the backend applies the pattern.

Source

fn close<'async_trait>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = SmbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,

Close the handle. Boxed self lets implementors consume internal state.

Provided Methods§

Source

fn write_owned<'life0, 'async_trait>( &'life0 self, offset: u64, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = SmbResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write owned data at offset. Backends that need ownership across a blocking boundary can override this to avoid an extra copy.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§