Skip to main content
Glama

microsandbox

by microsandbox
seekable.rs2.18 kB
//! `microsandbox_utils::seekable` is a module containing seekable utilities for the microsandbox project. use std::{ io::{self, SeekFrom}, pin::Pin, task::{Context, Poll}, }; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf}; //-------------------------------------------------------------------------------------------------- // Types //-------------------------------------------------------------------------------------------------- /// A seekable reader that always reads zero bytes and reports position as 0. #[derive(Debug)] pub struct EmptySeekableReader; /// A seekable writer that always writes zero bytes and reports position as 0. #[derive(Debug)] pub struct EmptySeekableWriter; //-------------------------------------------------------------------------------------------------- // Traits //-------------------------------------------------------------------------------------------------- /// A trait that extends the `AsyncRead` and `AsyncSeek` traits to allow for seeking. pub trait SeekableReader: AsyncRead + AsyncSeek {} /// A trait that extends the `AsyncWrite` and `AsyncSeek` traits to allow for seeking. pub trait SeekableWriter: AsyncWrite + AsyncSeek {} //-------------------------------------------------------------------------------------------------- // Trait Implementations //-------------------------------------------------------------------------------------------------- impl<T> SeekableReader for T where T: AsyncRead + AsyncSeek {} impl<T> SeekableWriter for T where T: AsyncWrite + AsyncSeek {} // Implement AsyncRead by always reading zero bytes impl AsyncRead for EmptySeekableReader { fn poll_read( self: Pin<&mut Self>, _cx: &mut Context<'_>, _buf: &mut ReadBuf<'_>, ) -> Poll<io::Result<()>> { Poll::Ready(Ok(())) } } // Implement AsyncSeek by always claiming the new position is 0 impl AsyncSeek for EmptySeekableReader { fn start_seek(self: Pin<&mut Self>, _position: SeekFrom) -> io::Result<()> { Ok(()) } fn poll_complete(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<u64>> { Poll::Ready(Ok(0)) } }

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