pub struct ManyAttachments { /* private fields */ }Expand description
Represents a has_many_attached relation.
Implementations§
Source§impl ManyAttachments
impl ManyAttachments
Sourcepub fn new(
record_type: impl Into<String>,
record_id: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn new( record_type: impl Into<String>, record_id: impl Into<String>, name: impl Into<String>, ) -> Self
Creates an empty collection attachment relation.
Sourcepub fn attach(&mut self, blob: Blob) -> Result<&Attachment, AttachmentError>
pub fn attach(&mut self, blob: Blob) -> Result<&Attachment, AttachmentError>
Sourcepub fn attach_many<I>(&mut self, blobs: I) -> Result<(), AttachmentError>where
I: IntoIterator<Item = Blob>,
pub fn attach_many<I>(&mut self, blobs: I) -> Result<(), AttachmentError>where
I: IntoIterator<Item = Blob>,
Appends several blobs to the collection.
§Errors
Returns an error when any attachment cannot be built.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Returns whether at least one blob is attached.
Sourcepub fn attachments(&self) -> &[Attachment]
pub fn attachments(&self) -> &[Attachment]
Returns all attachments in insertion order.
Sourcepub fn blobs(&self) -> impl Iterator<Item = &Blob>
pub fn blobs(&self) -> impl Iterator<Item = &Blob>
Returns an iterator over the attached blobs.
Sourcepub fn detach_blob(&mut self, blob_id: Uuid) -> Option<Attachment>
pub fn detach_blob(&mut self, blob_id: Uuid) -> Option<Attachment>
Removes an attachment by blob id.
Sourcepub async fn purge_all<S: StorageService + ?Sized>(
&mut self,
service: &S,
) -> Result<Vec<Attachment>, AttachmentError>
pub async fn purge_all<S: StorageService + ?Sized>( &mut self, service: &S, ) -> Result<Vec<Attachment>, AttachmentError>
Purges all attached blobs from storage and clears the collection.
§Errors
Returns an error when any storage delete fails.
Sourcepub fn purge_all_sync<S: StorageService + ?Sized>(
&mut self,
service: &S,
) -> Result<Vec<Attachment>, AttachmentError>
pub fn purge_all_sync<S: StorageService + ?Sized>( &mut self, service: &S, ) -> Result<Vec<Attachment>, AttachmentError>
Purges all attached blobs from storage and clears the collection using the thread-local runtime.
§Errors
Returns an error when any storage delete fails.
Trait Implementations§
Source§impl Clone for ManyAttachments
impl Clone for ManyAttachments
Source§fn clone(&self) -> ManyAttachments
fn clone(&self) -> ManyAttachments
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ManyAttachments
impl RefUnwindSafe for ManyAttachments
impl Send for ManyAttachments
impl Sync for ManyAttachments
impl Unpin for ManyAttachments
impl UnsafeUnpin for ManyAttachments
impl UnwindSafe for ManyAttachments
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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