#[non_exhaustive]pub struct Attachment { /* private fields */ }Expand description
A file in a composer: what the strip shows for it.
The id comes from the domain and is unique in the composer. The
progress is a percentage: None for a file that is ready, zero for one
that is queued, and above zero while it uploads. Setting it back to
None finishes the upload. A queued tile shows its ring at zero and
can be removed, an uploading tile shows the counter and cannot, and a
ready tile can be removed. Send waits for every attachment to be ready.
use gpui_cn::{Attachment, AttachmentKind};
let report = Attachment::new("a1", "report.xlsx").progress(55.);
assert_eq!(report.kind_of(), AttachmentKind::Spreadsheet);Implementations§
Source§impl Attachment
impl Attachment
Sourcepub fn new(id: impl Into<SharedString>, name: impl Into<SharedString>) -> Self
pub fn new(id: impl Into<SharedString>, name: impl Into<SharedString>) -> Self
A ready attachment. The kind comes from the name’s extension.
Sourcepub fn kind(self, kind: AttachmentKind) -> Self
pub fn kind(self, kind: AttachmentKind) -> Self
The kind, in place of the one the name’s extension gives.
Sourcepub fn progress(self, progress: impl Into<Option<f32>>) -> Self
pub fn progress(self, progress: impl Into<Option<f32>>) -> Self
The upload progress as a percentage, clamped to 0..=100.
Sourcepub fn image(self, source: impl Into<ImageSource>) -> Self
pub fn image(self, source: impl Into<ImageSource>) -> Self
The picture an image attachment shows as its thumbnail. It makes the attachment an image.
Sourcepub fn id(&self) -> &SharedString
pub fn id(&self) -> &SharedString
The id.
Sourcepub fn name(&self) -> &SharedString
pub fn name(&self) -> &SharedString
The file name.
Sourcepub fn kind_of(&self) -> AttachmentKind
pub fn kind_of(&self) -> AttachmentKind
The kind.
Sourcepub fn progress_percent(&self) -> Option<f32>
pub fn progress_percent(&self) -> Option<f32>
The upload progress, if the file is not ready.
Sourcepub fn set_progress(&mut self, progress: Option<f32>)
pub fn set_progress(&mut self, progress: Option<f32>)
Replaces the upload progress, as progress.
Sourcepub fn status(&self) -> AttachmentStatus
pub fn status(&self) -> AttachmentStatus
Where the attachment is in its life.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Attachment
impl !Send for Attachment
impl !Sync for Attachment
impl !UnwindSafe for Attachment
impl Freeze for Attachment
impl Unpin for Attachment
impl UnsafeUnpin for Attachment
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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