pub struct FileService { /* private fields */ }Expand description
File service for handling file uploads and downloads
Uses a shared Arc
Implementations§
Source§impl FileService
impl FileService
Sourcepub fn new(manager: Arc<FileManager>) -> Self
pub fn new(manager: Arc<FileManager>) -> Self
Create a new file service with the given file manager
§Arguments
manager- Shared FileManager instance
§Example
ⓘ
use agent_diva_files::{FileManager, FileConfig};
use agent_diva_manager::file_service::FileService;
use std::sync::Arc;
let config = FileConfig::default();
let manager = Arc::new(FileManager::new(config).await?);
let file_service = FileService::new(manager);Sourcepub async fn upload_file(
&self,
file_name: &str,
bytes: Vec<u8>,
channel: &str,
message_id: Option<&str>,
) -> Result<FileAttachment>
pub async fn upload_file( &self, file_name: &str, bytes: Vec<u8>, channel: &str, message_id: Option<&str>, ) -> Result<FileAttachment>
Upload a file and return a FileAttachment
§Arguments
file_name- Original file namebytes- File contentchannel- Source channel (e.g., “ui”, “telegram”)message_id- Optional message ID for association
Sourcepub fn manager(&self) -> &FileManager
pub fn manager(&self) -> &FileManager
Get the underlying FileManager
Sourcepub fn manager_arc(&self) -> Arc<FileManager>
pub fn manager_arc(&self) -> Arc<FileManager>
Get a clone of the Arc
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileService
impl !RefUnwindSafe for FileService
impl Send for FileService
impl Sync for FileService
impl Unpin for FileService
impl UnsafeUnpin for FileService
impl !UnwindSafe for FileService
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> Erasable for T
impl<T> Erasable for T
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