pub struct OneAttachment { /* private fields */ }Expand description
Represents a has_one_attached relation.
Implementations§
Source§impl OneAttachment
impl OneAttachment
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 one-to-one attachment relation.
Sourcepub fn attach(&mut self, blob: Blob) -> Result<&Attachment, AttachmentError>
pub fn attach(&mut self, blob: Blob) -> Result<&Attachment, AttachmentError>
Attaches a blob, replacing any existing attachment.
§Errors
Returns an error when the attachment cannot be built.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Returns whether a blob is currently attached.
Sourcepub fn attachment(&self) -> Option<&Attachment>
pub fn attachment(&self) -> Option<&Attachment>
Returns the current attachment, if any.
Sourcepub fn detach(&mut self) -> Option<Attachment>
pub fn detach(&mut self) -> Option<Attachment>
Removes the current attachment and returns it.
Sourcepub async fn purge<S: StorageService + ?Sized>(
&mut self,
service: &S,
) -> Result<Option<Attachment>, AttachmentError>
pub async fn purge<S: StorageService + ?Sized>( &mut self, service: &S, ) -> Result<Option<Attachment>, AttachmentError>
Purges the current attachment from storage and detaches it.
§Errors
Returns an error when the storage service delete fails.
Sourcepub fn purge_sync<S: StorageService + ?Sized>(
&mut self,
service: &S,
) -> Result<Option<Attachment>, AttachmentError>
pub fn purge_sync<S: StorageService + ?Sized>( &mut self, service: &S, ) -> Result<Option<Attachment>, AttachmentError>
Purges the current attachment from storage and detaches it using the thread-local runtime.
§Errors
Returns an error when the storage service delete fails.
Trait Implementations§
Source§impl Clone for OneAttachment
impl Clone for OneAttachment
Source§fn clone(&self) -> OneAttachment
fn clone(&self) -> OneAttachment
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 OneAttachment
impl RefUnwindSafe for OneAttachment
impl Send for OneAttachment
impl Sync for OneAttachment
impl Unpin for OneAttachment
impl UnsafeUnpin for OneAttachment
impl UnwindSafe for OneAttachment
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