pub struct Share { /* private fields */ }Expand description
One share definition, attached to a single backend.
Implementations§
Sourcepub fn new(name: impl Into<String>, backend: impl ShareBackend) -> Self
pub fn new(name: impl Into<String>, backend: impl ShareBackend) -> Self
Build a new share with the given name and backend.
Sourcepub fn public(self) -> Self
pub fn public(self) -> Self
Anonymous + authenticated read+write. A logon as guest with an
empty password, which the Finder sends for Connect As Guest, gets the
same access as an anonymous session unless a user of that name is
configured; the name matches in any case. Guest and anonymous traffic
is neither signed nor encrypted, so a client that requires signing
gets no guest session.
Sourcepub fn public_read_only(self) -> Self
pub fn public_read_only(self) -> Self
Anonymous + authenticated read-only. Guest logons get the same
access as anonymous sessions, as with Share::public.
Sourcepub fn user(self, name: impl Into<String>, access: Access) -> Self
pub fn user(self, name: impl Into<String>, access: Access) -> Self
Grant access to the given (already-registered) user. Multiple calls
accumulate.
Sourcepub fn encrypt_data(self) -> Self
pub fn encrypt_data(self) -> Self
Encrypt all traffic to this share. SMB 3.x clients that cannot
encrypt, SMB 2.x clients, and anonymous and guest sessions are
refused at TREE_CONNECT unless
SmbServerBuilder::reject_unencrypted_access is turned off.
Sourcepub fn leases(self, enabled: bool) -> Self
pub fn leases(self, enabled: bool) -> Self
Grant read, handle and write caching leases on this share’s files. A client holding one caches what it reads, keeps files open after its applications close them, and caches what it writes while every other open of the file holds the same lease or is attribute-only.
Opens on the share that do not hold the lease, from another client or from the same client under another lease key or none, break it: the client writes back and stops caching writes before such an open, drops cached data before a write, a size change, a byte-range lock or an overwrite through it, and closes the handles it keeps before an open they block, a rename or delete of the file, a rename over it, or a rename of a directory above it. Attribute-only opens and opens holding the same lease break nothing. An open or rename that needs the client to write back or close first waits until the client acknowledges the break or closes, or until the break times out 35 seconds after the server sent it; a byte-range lock is refused instead until the client has written back. On by default.
Changes made outside the server, or through another share over the same directory, break no lease: clients keep serving the old data. Turn leases off for such a share.
Sourcepub fn durable_handles(self, enabled: bool) -> Self
pub fn durable_handles(self, enabled: bool) -> Self
Keep a client’s open files for a while after its connection drops or
it logs off, with their share modes, byte-range locks and leases, so
the client can take them back when it reconnects. Only files opened
with a durable handle request and a lease that caches handles are
kept, so this does nothing when leases are off. The backend handle
stays open for SmbServerBuilder::durable_handle_timeout, or the
time a version 2 request was granted, or until an open, write, size change, byte-range lock, rename or
delete through an open that does not hold the lease needs what the
lease caches, which closes the file at once. The same user, from the
same client, on this share, takes a kept file back with a durable
handle reconnect that names the file and its lease, and for a version
2 open its CreateGuid. Another user gets STATUS_ACCESS_DENIED;
another client, share, lease or CreateGuid gets
STATUS_OBJECT_NAME_NOT_FOUND. A kept file whose rights exceed what
the user’s tree on the share grants at the reconnect is closed
instead. Version 1 and version 2 requests are both served; the
PERSISTENT flag is ignored. On by default.
Sourcepub fn change_notify(self, enabled: bool) -> Self
pub fn change_notify(self, enabled: bool) -> Self
Answer change notification requests: a client watching a folder, as
Explorer and Finder do for an open window, hears when a file or
folder in it is created, deleted, renamed, written, truncated or
overwritten, or has its attributes or times set, through any
connection to this share. A write is reported when the open that
wrote it closes. Changes made outside the server, or through another
share over the same directory, are reported only by a backend that
watches for them: LocalFsBackend does on Linux, for the entries
directly in a watched folder. When off, such requests fail with
STATUS_NOT_SUPPORTED. On by default.
Sourcepub fn listed(self, listed: bool) -> Self
pub fn listed(self, listed: bool) -> Self
Whether the share appears when clients list the server’s shares.
An unlisted share is still reachable by name, and a client that may
connect to it can still look it up by name, so this is not access
control. Clients hide shares whose name ends in $ from ordinary
lists; net view /all and smbclient -L show them. On by default.