MCPcopy Create free account
hub / github.com/chatmail/core / set_file_from_bytes

Method set_file_from_bytes

src/message.rs:1148–1161  ·  view source on GitHub ↗

Creates a new blob and sets it as a file associated with a message. In order to deduplicate files that contain the same data, the file will be named ` . `, e.g. `ce940175885d7b78f7b7e9f1396611f.jpg`. NOTE: The file must not be modified after this function was called.

(
        &mut self,
        context: &Context,
        name: &str,
        data: &[u8],
        filemime: Option<&str>,
    )

Source from the content-addressed store, hash-verified

1146 ///
1147 /// NOTE: The file must not be modified after this function was called.
1148 pub fn set_file_from_bytes(
1149 &mut self,
1150 context: &Context,
1151 name: &str,
1152 data: &[u8],
1153 filemime: Option<&str>,
1154 ) -> Result<()> {
1155 let blob = BlobObject::create_and_deduplicate_from_bytes(context, data, name)?;
1156 self.param.set(Param::Filename, name);
1157 self.param.set(Param::File, blob.as_name());
1158 self.param.set_optional(Param::MimeType, filemime);
1159
1160 Ok(())
1161 }
1162
1163 /// Makes message a vCard-containing message using the specified contacts.
1164 pub async fn make_vcard(&mut self, context: &Context, contacts: &[ContactId]) -> Result<()> {

Callers 15

test_get_summary_textFunction · 0.80
send_statsFunction · 0.80
make_vcardMethod · 0.80
test_can_communicateFunction · 0.80
test_can_reconnectFunction · 0.80
test_parallel_connectFunction · 0.80
test_webxdc_resendFunction · 0.80
testFunction · 0.80

Calls 3

as_nameMethod · 0.80
set_optionalMethod · 0.80
setMethod · 0.45

Tested by 15

test_get_summary_textFunction · 0.64
test_can_communicateFunction · 0.64
test_can_reconnectFunction · 0.64
test_parallel_connectFunction · 0.64
test_webxdc_resendFunction · 0.64
testFunction · 0.64
create_webxdc_instanceFunction · 0.64