Skip to main content

Handle

Trait Handle 

Source
pub trait Handle: Send + Sync {
Show 13 methods // 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 methods 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 { ... } fn link_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SmbResult<u32>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn dir_is_empty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SmbResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn watch<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SmbResult<Option<Box<dyn DirWatch>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

A live open file or directory handle.

One handle per CREATE. close runs when CLOSE arrives, and when the tree, session or connection the open belongs to ends. A durable open’s handle stays open past the end of its session or connection, until its client takes the open back, the open expires, or something else closes it; see the crate docs.

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. The . and .. entries are left out; QUERY_DIRECTORY adds them.

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.

Number of hard links to the file, reported as NumberOfLinks by FileStandardInformation. 0 means the file has been deleted while open. The default reports 1.

Source

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

True if this directory has no entries other than . and .., including entries Handle::list_dir leaves out. The default checks list_dir(None), so a backend whose listing hides entries overrides it.

Source

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

Watch this directory for changes to its entries made by anyone, including outside the server. The server asks one open of a watched directory and shares the watch among every watch of that directory; it may outlive the handle, and is dropped with the directory’s last watch. The default returns Ok(None): the server then reports only the changes made through it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§