tauri-plugin-medialibrary 0.14.0

A tauri plugin to access the systems media library (e.g. the android medialibrary)
Documentation
use allmytoes::{AMTConfiguration, ThumbSize, AMT};
use base64::{engine::general_purpose, Engine as _};
use std::fs;
use std::path::Path;

use crate::{thumbnail_provider::ThumbnailProvider, Error, GetThumbnailResponse};

pub struct AmtThumbnailProvider;

impl ThumbnailProvider for AmtThumbnailProvider {
    fn get_thumbnail(path: &Path) -> crate::Result<GetThumbnailResponse> {
        let configuration = AMTConfiguration::default();
        let amt = AMT::new(&configuration);

        let thumb_size = ThumbSize::Large;
        match amt.get(path, thumb_size) {
            Ok(thumb) => {
                let bytes = fs::read(&thumb.path)?;
                let content = general_purpose::STANDARD.encode(&bytes);

                Ok(GetThumbnailResponse { content })
            }
            Err(error) => Err(Error::AllMyToes(format!("get_thumbnail error: {error:?}"))),
        }
    }
}