pub struct MediaManager { /* private fields */ }Expand description
Manages media uploads and downloads against the Langfuse API.
Cheaply cloneable (backed by Arc). Background uploads are bounded
by a semaphore whose size is controlled by
LangfuseConfig::media_upload_thread_count.
Implementations§
Source§impl MediaManager
impl MediaManager
Sourcepub fn new(config: &LangfuseConfig) -> Self
pub fn new(config: &LangfuseConfig) -> Self
Create a new MediaManager from the given configuration.
Sourcepub async fn upload(
&self,
trace_id: &str,
observation_id: Option<&str>,
field: &str,
media: &LangfuseMedia,
) -> Result<String, LangfuseError>
pub async fn upload( &self, trace_id: &str, observation_id: Option<&str>, field: &str, media: &LangfuseMedia, ) -> Result<String, LangfuseError>
Upload media and return the media ID.
This performs a two-step upload:
- Request a presigned upload URL from the Langfuse API.
- Upload the raw bytes to the presigned URL.
Sourcepub fn upload_background(
&self,
trace_id: String,
observation_id: Option<String>,
field: String,
media: LangfuseMedia,
)
pub fn upload_background( &self, trace_id: String, observation_id: Option<String>, field: String, media: LangfuseMedia, )
Upload media in a background task.
Spawns a tokio task that acquires a permit from the upload semaphore
(bounded by media_upload_thread_count) before performing the upload.
Errors are logged via tracing::warn and otherwise silently dropped.
Sourcepub async fn fetch(
&self,
media_id: &str,
) -> Result<LangfuseMedia, LangfuseError>
pub async fn fetch( &self, media_id: &str, ) -> Result<LangfuseMedia, LangfuseError>
Fetch media by ID.
Retrieves the media metadata from the Langfuse API, then downloads the actual content from the returned URL.
Trait Implementations§
Source§impl Clone for MediaManager
impl Clone for MediaManager
Source§fn clone(&self) -> MediaManager
fn clone(&self) -> MediaManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MediaManager
impl !RefUnwindSafe for MediaManager
impl Send for MediaManager
impl Sync for MediaManager
impl Unpin for MediaManager
impl UnsafeUnpin for MediaManager
impl !UnwindSafe for MediaManager
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