pub struct UploadFileBuilder<'a> { /* private fields */ }Expand description
Builder for the file-upload operation returned by Session::upload_file.
Call .peer(id) (required) and optionally chain .metadata(),
.configuration(), .created_at() before calling .send().
Implementations§
Source§impl UploadFileBuilder<'_>
impl UploadFileBuilder<'_>
Sourcepub fn peer(self, id: impl Into<String>) -> Self
pub fn peer(self, id: impl Into<String>) -> Self
Set the peer that owns the uploaded file (required).
§Examples
let _builder = session.upload_file(honcho_ai::FileSource::bytes("f.txt", b"data", "text/plain")).peer("alice");Sourcepub fn metadata(self, value: Value) -> Self
pub fn metadata(self, value: Value) -> Self
Attach arbitrary JSON metadata to the created message(s).
§Examples
let _builder = session.upload_file(honcho_ai::FileSource::bytes("f.txt", b"data", "text/plain"))
.peer("alice")
.metadata(serde_json::json!({"source": "upload"}));Sourcepub fn configuration(self, value: Value) -> Self
pub fn configuration(self, value: Value) -> Self
Attach configuration to the created message(s).
§Examples
let _builder = session.upload_file(honcho_ai::FileSource::bytes("f.txt", b"data", "text/plain"))
.peer("alice")
.configuration(serde_json::json!({"reasoning": true}));Sourcepub fn created_at(self, dt: DateTime<Utc>) -> Self
pub fn created_at(self, dt: DateTime<Utc>) -> Self
Override the creation timestamp (ISO 3339).
§Examples
let _builder = session.upload_file(honcho_ai::FileSource::bytes("f.txt", b"data", "text/plain"))
.peer("alice")
.created_at(chrono::Utc::now());Sourcepub async fn send(self) -> Result<Vec<Message>>
pub async fn send(self) -> Result<Vec<Message>>
Resolve the file source, build the multipart form, POST, and return the created messages.
§Examples
let msgs = session
.upload_file(honcho_ai::FileSource::bytes("doc.pdf", b"data", "application/pdf"))
.peer("alice")
.send()
.await?;§Errors
Returns HonchoError::Validation if no peer was set via .peer().
Auto Trait Implementations§
impl<'a> Freeze for UploadFileBuilder<'a>
impl<'a> !RefUnwindSafe for UploadFileBuilder<'a>
impl<'a> Send for UploadFileBuilder<'a>
impl<'a> !Sync for UploadFileBuilder<'a>
impl<'a> Unpin for UploadFileBuilder<'a>
impl<'a> UnsafeUnpin for UploadFileBuilder<'a>
impl<'a> !UnwindSafe for UploadFileBuilder<'a>
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