Skip to main content
Glama

microsandbox

by microsandbox
file.rs1.18 kB
//! Utility functions for working with files. use std::path::Path; use oci_spec::image::DigestAlgorithm; use sha2::{Digest, Sha256, Sha384, Sha512}; use tokio::{fs::File, io::AsyncReadExt}; use crate::{MicrosandboxError, MicrosandboxResult}; //-------------------------------------------------------------------------------------------------- // Functions //-------------------------------------------------------------------------------------------------- /// Gets the hash of a file. pub async fn get_file_hash( path: &Path, algorithm: &DigestAlgorithm, ) -> MicrosandboxResult<Vec<u8>> { let mut file = File::open(path).await?; let mut buffer = Vec::new(); file.read_to_end(&mut buffer).await?; let hash = match algorithm { DigestAlgorithm::Sha256 => Sha256::digest(&buffer).to_vec(), DigestAlgorithm::Sha384 => Sha384::digest(&buffer).to_vec(), DigestAlgorithm::Sha512 => Sha512::digest(&buffer).to_vec(), _ => { return Err(MicrosandboxError::UnsupportedImageHashAlgorithm(format!( "Unsupported algorithm: {}", algorithm ))); } }; Ok(hash) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/microsandbox/microsandbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server