Memory
In memory service support. (BTreeMap Based)
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
- list
- presign
- blocking
Example
Via Builder
use std::sync::Arc;
use anyhow::Result;
use opendal::services::Memory;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Memory::default();
builder.root("/tmp");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("root".to_string(), "/path/to/dir".to_string());
let op: Operator = Operator::via_map(Scheme::Memory, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("memory", {
root: "/path/to/dir",
});
}
import opendal
op = opendal.Operator("memory",
root="/path/to/dir",
)