pub struct Binary {
pub content_type: String,
pub source: BinarySource,
pub name: Option<String>,
}Expand description
Binary payload attached to a message (e.g., image or PDF).
Fields§
§content_type: StringMIME type, such as “image/png” or “application/pdf”.
source: BinarySourceWhere the bytes come from (base64 or URL).
name: Option<String>Optional display name or filename.
Implementations§
Source§impl Binary
Constructors
impl Binary
Constructors
Sourcepub fn new(
content_type: impl Into<String>,
source: BinarySource,
name: Option<String>,
) -> Self
pub fn new( content_type: impl Into<String>, source: BinarySource, name: Option<String>, ) -> Self
Construct a new Binary value.
Sourcepub fn from_base64(
content_type: impl Into<String>,
content: impl Into<Arc<str>>,
name: Option<String>,
) -> Binary
pub fn from_base64( content_type: impl Into<String>, content: impl Into<Arc<str>>, name: Option<String>, ) -> Binary
Create a binary from a base64 payload.
- content_type: MIME type (e.g., “image/png”, “application/pdf”).
- content: base64-encoded bytes.
- name: optional display name or filename.
Source§impl Binary
is_.., into_.. Accessors
impl Binary
is_.., into_.. Accessors
Sourcepub fn is_image(&self) -> bool
pub fn is_image(&self) -> bool
Returns true if this binary is an image (content_type starts with “image/”).
Sourcepub fn is_audio(&self) -> bool
pub fn is_audio(&self) -> bool
Returns true if this binary is an audio file (content_type starts with “audio/”).
Source§impl Binary
Computed assessors
impl Binary
Computed assessors
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns an approximate in-memory size of this Binary, in bytes,
computed as the sum of the UTF-8 lengths of:
content_typename(if any)- the underlying URL or base64 string in
source.
This does not return the decoded byte length of the file. This does not return the size of the URL content
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Binary
impl<'de> Deserialize<'de> for Binary
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Binary> for ContentPart
impl From<Binary> for ContentPart
Source§impl From<Binary> for MessageContent
impl From<Binary> for MessageContent
Auto Trait Implementations§
impl Freeze for Binary
impl RefUnwindSafe for Binary
impl Send for Binary
impl Sync for Binary
impl Unpin for Binary
impl UnsafeUnpin for Binary
impl UnwindSafe for Binary
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