pub struct Disk { /* private fields */ }Expand description
A cloneable filesystem disk over a shared ObjectStore.
Implementations§
Source§impl Disk
impl Disk
Sourcepub fn object_store(
store: Arc<dyn ObjectStore>,
prefix: Option<&str>,
) -> StorageResult<Self>
pub fn object_store( store: Arc<dyn ObjectStore>, prefix: Option<&str>, ) -> StorageResult<Self>
Creates a disk from an existing object store and optional store prefix.
Sourcepub fn local(root: impl AsRef<FilePath>) -> StorageResult<Self>
pub fn local(root: impl AsRef<FilePath>) -> StorageResult<Self>
Creates a local disk rooted at an explicitly configured directory.
Like Laravel’s Flysystem local driver, the directory is a trusted root. Direct operations follow operating-system symbolic links.
Sourcepub fn with_public_url(self, public_url: Url) -> Self
pub fn with_public_url(self, public_url: Url) -> Self
Configures a public base URL for this disk.
The URL represents the disk root; object path segments are appended with URL encoding. This does not make objects public by itself.
Sourcepub async fn exists(&self, path: impl AsRef<str>) -> StorageResult<bool>
pub async fn exists(&self, path: impl AsRef<str>) -> StorageResult<bool>
Returns whether an object exists. Backend failures are not treated as misses.
Sourcepub async fn missing(&self, path: impl AsRef<str>) -> StorageResult<bool>
pub async fn missing(&self, path: impl AsRef<str>) -> StorageResult<bool>
Returns whether an object does not exist.
Sourcepub async fn get(&self, path: impl AsRef<str>) -> StorageResult<Bytes>
pub async fn get(&self, path: impl AsRef<str>) -> StorageResult<Bytes>
Reads an entire object into memory.
Sourcepub async fn read_stream(
&self,
path: impl AsRef<str>,
) -> StorageResult<ReadStream>
pub async fn read_stream( &self, path: impl AsRef<str>, ) -> StorageResult<ReadStream>
Opens an object as an asynchronous byte stream.
Sourcepub async fn put(
&self,
path: impl AsRef<str>,
contents: Bytes,
) -> StorageResult<()>
pub async fn put( &self, path: impl AsRef<str>, contents: Bytes, ) -> StorageResult<()>
Atomically writes a buffered object, replacing an existing object.
Sourcepub async fn put_stream<S, E>(
&self,
path: impl AsRef<str>,
stream: S,
) -> StorageResult<u64>
pub async fn put_stream<S, E>( &self, path: impl AsRef<str>, stream: S, ) -> StorageResult<u64>
Streams an object through the backend multipart API, replacing an existing object.
Failed streams abort the backend upload before returning where the backend permits it.
Sourcepub async fn delete(&self, path: impl AsRef<str>) -> StorageResult<()>
pub async fn delete(&self, path: impl AsRef<str>) -> StorageResult<()>
Deletes an object. Deleting an absent object succeeds, matching Laravel’s default behavior.
Sourcepub async fn copy(
&self,
source: impl AsRef<str>,
destination: impl AsRef<str>,
) -> StorageResult<()>
pub async fn copy( &self, source: impl AsRef<str>, destination: impl AsRef<str>, ) -> StorageResult<()>
Copies an object, replacing the destination when supported by the backend.
Sourcepub async fn move_file(
&self,
source: impl AsRef<str>,
destination: impl AsRef<str>,
) -> StorageResult<()>
pub async fn move_file( &self, source: impl AsRef<str>, destination: impl AsRef<str>, ) -> StorageResult<()>
Moves an object, replacing the destination when supported by the backend.
Sourcepub async fn metadata(
&self,
path: impl AsRef<str>,
) -> StorageResult<FileMetadata>
pub async fn metadata( &self, path: impl AsRef<str>, ) -> StorageResult<FileMetadata>
Returns object size and last-modified metadata.
Sourcepub async fn list(
&self,
prefix: Option<&str>,
) -> StorageResult<Vec<FileMetadata>>
pub async fn list( &self, prefix: Option<&str>, ) -> StorageResult<Vec<FileMetadata>>
Lists objects below an optional disk-relative prefix.
Sourcepub fn url(&self, path: impl AsRef<str>) -> StorageResult<Url>
pub fn url(&self, path: impl AsRef<str>) -> StorageResult<Url>
Generates a URL using the configured public base URL.
Sourcepub fn visibility(&self, _path: impl AsRef<str>) -> StorageResult<()>
pub fn visibility(&self, _path: impl AsRef<str>) -> StorageResult<()>
Reports that generic object stores do not expose portable visibility mutation.
Sourcepub fn temporary_url(&self, _path: impl AsRef<str>) -> StorageResult<Url>
pub fn temporary_url(&self, _path: impl AsRef<str>) -> StorageResult<Url>
Reports that this initial generic disk does not expose provider-specific URL signing.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Disk
impl !UnwindSafe for Disk
impl Forget for Disk
impl Freeze for Disk
impl Move for Disk
impl Send for Disk
impl Sync for Disk
impl Unpin for Disk
impl UnsafeUnpin for Disk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more