or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-operations.mdindex.mdlayers.mdservices.mdtypes.md

services.mddocs/

0

# Storage Services

1

2

OpenDAL provides unified access to 50+ storage services through a consistent builder pattern. Each service implements the same `Operator` interface while handling service-specific protocols, authentication, and configuration internally.

3

4

## Capabilities

5

6

### Service Builder Pattern

7

8

All services follow a consistent configuration pattern using the `Builder` trait.

9

10

```rust { .api }

11

pub trait Builder: Default {

12

const SCHEME: Scheme;

13

type Accessor: Access;

14

15

/// Create builder from key-value configuration map

16

fn from_map(map: HashMap<String, String>) -> Self;

17

18

/// Build the accessor for this service

19

fn build(&mut self) -> Result<Self::Accessor>;

20

}

21

22

/// Initialize any service using the builder pattern

23

let mut builder = ServiceType::default();

24

builder.option1("value1").option2("value2");

25

let op = Operator::new(builder)?.finish();

26

```

27

28

### Cloud Object Storage Services

29

30

Major cloud storage providers with S3-compatible APIs.

31

32

```rust { .api }

33

/// Amazon S3 and S3-compatible services

34

pub struct S3;

35

impl S3 {

36

pub fn bucket(&mut self, bucket: &str) -> &mut Self;

37

pub fn region(&mut self, region: &str) -> &mut Self;

38

pub fn access_key_id(&mut self, key: &str) -> &mut Self;

39

pub fn secret_access_key(&mut self, secret: &str) -> &mut Self;

40

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

41

pub fn role_arn(&mut self, arn: &str) -> &mut Self;

42

pub fn external_id(&mut self, id: &str) -> &mut Self;

43

}

44

45

/// Google Cloud Storage

46

pub struct Gcs;

47

impl Gcs {

48

pub fn bucket(&mut self, bucket: &str) -> &mut Self;

49

pub fn credential(&mut self, credential: &str) -> &mut Self;

50

pub fn credential_path(&mut self, path: &str) -> &mut Self;

51

}

52

53

/// Azure Blob Storage

54

pub struct Azblob;

55

impl Azblob {

56

pub fn container(&mut self, container: &str) -> &mut Self;

57

pub fn account_name(&mut self, account: &str) -> &mut Self;

58

pub fn account_key(&mut self, key: &str) -> &mut Self;

59

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

60

}

61

62

/// Alibaba Cloud Object Storage Service

63

pub struct Oss;

64

impl Oss {

65

pub fn bucket(&mut self, bucket: &str) -> &mut Self;

66

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

67

pub fn access_key_id(&mut self, key: &str) -> &mut Self;

68

pub fn access_key_secret(&mut self, secret: &str) -> &mut Self;

69

}

70

71

/// Additional cloud storage services

72

pub struct Obs; // Huawei Object Storage Service

73

pub struct Cos; // Tencent Cloud Object Storage

74

pub struct B2; // Backblaze B2

75

```

76

77

**Usage Examples:**

78

79

```rust

80

use opendal::services::{S3, Gcs, Azblob};

81

82

// Amazon S3

83

let mut s3_builder = S3::default();

84

s3_builder

85

.bucket("my-bucket")

86

.region("us-west-2")

87

.access_key_id("AKIAIOSFODNN7EXAMPLE")

88

.secret_access_key("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");

89

let s3_op = Operator::new(s3_builder)?.finish();

90

91

// Google Cloud Storage

92

let mut gcs_builder = Gcs::default();

93

gcs_builder

94

.bucket("my-gcs-bucket")

95

.credential_path("/path/to/service-account.json");

96

let gcs_op = Operator::new(gcs_builder)?.finish();

97

98

// Azure Blob Storage

99

let mut azure_builder = Azblob::default();

100

azure_builder

101

.container("my-container")

102

.account_name("mystorageaccount")

103

.account_key("YWNjb3VudGtleQ==");

104

let azure_op = Operator::new(azure_builder)?.finish();

105

```

106

107

### File System Services

108

109

Local and distributed file system access.

110

111

```rust { .api }

112

/// Local POSIX file system

113

pub struct Fs;

114

impl Fs {

115

pub fn root(&mut self, root: &str) -> &mut Self;

116

}

117

118

/// Hadoop Distributed File System

119

pub struct Hdfs;

120

impl Hdfs {

121

pub fn name_node(&mut self, name_node: &str) -> &mut Self;

122

pub fn user(&mut self, user: &str) -> &mut Self;

123

pub fn kerberos_ticket_cache_path(&mut self, path: &str) -> &mut Self;

124

}

125

126

/// Native HDFS implementation

127

pub struct HdfsNative;

128

impl HdfsNative {

129

pub fn name_node(&mut self, name_node: &str) -> &mut Self;

130

pub fn user(&mut self, user: &str) -> &mut Self;

131

}

132

133

/// WebDAV protocol

134

pub struct Webdav;

135

impl Webdav {

136

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

137

pub fn username(&mut self, username: &str) -> &mut Self;

138

pub fn password(&mut self, password: &str) -> &mut Self;

139

pub fn token(&mut self, token: &str) -> &mut Self;

140

}

141

142

/// FTP protocol

143

pub struct Ftp;

144

impl Ftp {

145

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

146

pub fn user(&mut self, user: &str) -> &mut Self;

147

pub fn password(&mut self, password: &str) -> &mut Self;

148

}

149

150

/// SFTP (SSH File Transfer Protocol)

151

pub struct Sftp;

152

impl Sftp {

153

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

154

pub fn user(&mut self, user: &str) -> &mut Self;

155

pub fn key(&mut self, key: &str) -> &mut Self;

156

pub fn password(&mut self, password: &str) -> &mut Self;

157

}

158

```

159

160

**Usage Examples:**

161

162

```rust

163

use opendal::services::{Fs, Hdfs, Webdav};

164

165

// Local file system

166

let mut fs_builder = Fs::default();

167

fs_builder.root("/data/storage");

168

let fs_op = Operator::new(fs_builder)?.finish();

169

170

// HDFS

171

let mut hdfs_builder = Hdfs::default();

172

hdfs_builder

173

.name_node("hdfs://namenode:9000")

174

.user("hadoop");

175

let hdfs_op = Operator::new(hdfs_builder)?.finish();

176

177

// WebDAV

178

let mut webdav_builder = Webdav::default();

179

webdav_builder

180

.endpoint("https://webdav.example.com/")

181

.username("user")

182

.password("pass");

183

let webdav_op = Operator::new(webdav_builder)?.finish();

184

```

185

186

### Database Services

187

188

Key-value stores, relational databases, and document databases.

189

190

```rust { .api }

191

/// Redis key-value store

192

pub struct Redis;

193

impl Redis {

194

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

195

pub fn username(&mut self, username: &str) -> &mut Self;

196

pub fn password(&mut self, password: &str) -> &mut Self;

197

pub fn db(&mut self, db: i64) -> &mut Self;

198

}

199

200

/// PostgreSQL database

201

pub struct Postgresql;

202

impl Postgresql {

203

pub fn connection_string(&mut self, connection: &str) -> &mut Self;

204

pub fn table(&mut self, table: &str) -> &mut Self;

205

pub fn key_field(&mut self, field: &str) -> &mut Self;

206

pub fn value_field(&mut self, field: &str) -> &mut Self;

207

}

208

209

/// MySQL database

210

pub struct Mysql;

211

impl Mysql {

212

pub fn connection_string(&mut self, connection: &str) -> &mut Self;

213

pub fn table(&mut self, table: &str) -> &mut Self;

214

pub fn key_field(&mut self, field: &str) -> &mut Self;

215

pub fn value_field(&mut self, field: &str) -> &mut Self;

216

}

217

218

/// SQLite database

219

pub struct Sqlite;

220

impl Sqlite {

221

pub fn connection_string(&mut self, connection: &str) -> &mut Self;

222

pub fn table(&mut self, table: &str) -> &mut Self;

223

pub fn key_field(&mut self, field: &str) -> &mut Self;

224

pub fn value_field(&mut self, field: &str) -> &mut Self;

225

}

226

227

/// MongoDB document database

228

pub struct Mongodb;

229

impl Mongodb {

230

pub fn connection_string(&mut self, connection: &str) -> &mut Self;

231

pub fn database(&mut self, database: &str) -> &mut Self;

232

pub fn collection(&mut self, collection: &str) -> &mut Self;

233

}

234

235

/// RocksDB embedded database

236

pub struct Rocksdb;

237

impl Rocksdb {

238

pub fn datadir(&mut self, dir: &str) -> &mut Self;

239

}

240

241

/// Additional database services

242

pub struct Foundationdb; // FoundationDB

243

pub struct Tikv; // TiKV distributed storage

244

pub struct Surrealdb; // SurrealDB multi-model database

245

pub struct Etcd; // etcd key-value store

246

```

247

248

**Usage Examples:**

249

250

```rust

251

use opendal::services::{Redis, Postgresql, Mongodb};

252

253

// Redis

254

let mut redis_builder = Redis::default();

255

redis_builder

256

.endpoint("redis://localhost:6379")

257

.db(0);

258

let redis_op = Operator::new(redis_builder)?.finish();

259

260

// PostgreSQL

261

let mut pg_builder = Postgresql::default();

262

pg_builder

263

.connection_string("postgresql://user:pass@localhost/db")

264

.table("file_storage")

265

.key_field("path")

266

.value_field("content");

267

let pg_op = Operator::new(pg_builder)?.finish();

268

269

// MongoDB

270

let mut mongo_builder = Mongodb::default();

271

mongo_builder

272

.connection_string("mongodb://localhost:27017")

273

.database("filestore")

274

.collection("files");

275

let mongo_op = Operator::new(mongo_builder)?.finish();

276

```

277

278

### Memory and Cache Services

279

280

In-memory storage and distributed caching solutions.

281

282

```rust { .api }

283

/// In-memory storage

284

pub struct Memory;

285

286

/// DashMap concurrent hashmap

287

pub struct Dashmap;

288

289

/// Memcached distributed cache

290

pub struct Memcached;

291

impl Memcached {

292

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

293

pub fn timeout(&mut self, timeout: Duration) -> &mut Self;

294

}

295

296

/// Moka high-performance cache

297

pub struct Moka;

298

impl Moka {

299

pub fn max_capacity(&mut self, capacity: u64) -> &mut Self;

300

pub fn time_to_live(&mut self, ttl: Duration) -> &mut Self;

301

pub fn time_to_idle(&mut self, tti: Duration) -> &mut Self;

302

}

303

304

/// MiniMoka lightweight cache

305

pub struct MiniMoka;

306

impl MiniMoka {

307

pub fn max_capacity(&mut self, capacity: u64) -> &mut Self;

308

pub fn time_to_live(&mut self, ttl: Duration) -> &mut Self;

309

pub fn time_to_idle(&mut self, tti: Duration) -> &mut Self;

310

}

311

312

/// Content-addressable cache

313

pub struct Cacache;

314

impl Cacache {

315

pub fn datadir(&mut self, dir: &str) -> &mut Self;

316

}

317

```

318

319

**Usage Examples:**

320

321

```rust

322

use opendal::services::{Memory, Moka, Memcached};

323

use std::time::Duration;

324

325

// In-memory storage

326

let memory_op = Operator::new(Memory::default())?.finish();

327

328

// Moka cache with TTL

329

let mut moka_builder = Moka::default();

330

moka_builder

331

.max_capacity(10000)

332

.time_to_live(Duration::from_secs(3600));

333

let moka_op = Operator::new(moka_builder)?.finish();

334

335

// Memcached

336

let mut memcached_builder = Memcached::default();

337

memcached_builder.endpoint("memcache://localhost:11211");

338

let memcached_op = Operator::new(memcached_builder)?.finish();

339

```

340

341

### Cloud Platform Services

342

343

Specialized services for major cloud platforms and SaaS providers.

344

345

```rust { .api }

346

/// GitHub repository storage

347

pub struct Github;

348

impl Github {

349

pub fn owner(&mut self, owner: &str) -> &mut Self;

350

pub fn repo(&mut self, repo: &str) -> &mut Self;

351

pub fn token(&mut self, token: &str) -> &mut Self;

352

}

353

354

/// Dropbox cloud storage

355

pub struct Dropbox;

356

impl Dropbox {

357

pub fn access_token(&mut self, token: &str) -> &mut Self;

358

pub fn refresh_token(&mut self, token: &str) -> &mut Self;

359

}

360

361

/// Microsoft OneDrive

362

pub struct Onedrive;

363

impl Onedrive {

364

pub fn access_token(&mut self, token: &str) -> &mut Self;

365

pub fn refresh_token(&mut self, token: &str) -> &mut Self;

366

}

367

368

/// Google Drive

369

pub struct Gdrive;

370

impl Gdrive {

371

pub fn access_token(&mut self, token: &str) -> &mut Self;

372

pub fn refresh_token(&mut self, token: &str) -> &mut Self;

373

}

374

375

/// Supabase storage

376

pub struct Supabase;

377

impl Supabase {

378

pub fn url(&mut self, url: &str) -> &mut Self;

379

pub fn key(&mut self, key: &str) -> &mut Self;

380

pub fn bucket(&mut self, bucket: &str) -> &mut Self;

381

}

382

383

/// Vercel Blob storage

384

pub struct VercelBlob;

385

impl VercelBlob {

386

pub fn token(&mut self, token: &str) -> &mut Self;

387

}

388

389

/// Additional platform services

390

pub struct Huggingface; // Hugging Face Hub

391

pub struct VercelArtifacts; // Vercel build artifacts

392

pub struct Icloud; // Apple iCloud

393

```

394

395

### Specialized Services

396

397

Unique storage solutions and protocol implementations.

398

399

```rust { .api }

400

/// InterPlanetary File System (IPFS)

401

pub struct Ipfs;

402

impl Ipfs {

403

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

404

}

405

406

/// Generic HTTP backend

407

pub struct Http;

408

impl Http {

409

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

410

pub fn username(&mut self, username: &str) -> &mut Self;

411

pub fn password(&mut self, password: &str) -> &mut Self;

412

}

413

414

/// Alluxio data orchestration

415

pub struct Alluxio;

416

impl Alluxio {

417

pub fn endpoint(&mut self, endpoint: &str) -> &mut Self;

418

}

419

420

/// Cloudflare services

421

pub struct CloudflareKv; // Cloudflare KV

422

pub struct D1; // Cloudflare D1 database

423

424

/// Additional specialized services

425

pub struct Atomicserver; // Atomic Server

426

pub struct Chainsafe; // ChainSafe storage

427

```

428

429

### Service Scheme Enumeration

430

431

All services are identified by their scheme for capability detection and configuration.

432

433

```rust { .api }

434

#[derive(Debug, Clone, Copy, PartialEq, Eq)]

435

pub enum Scheme {

436

Azblob,

437

Azdls,

438

Azfile,

439

B2,

440

Cacache,

441

Chainsafe,

442

CloudflareKv,

443

Compfs,

444

Cos,

445

D1,

446

Dashmap,

447

Dbfs,

448

Dropbox,

449

Etcd,

450

Foundationdb,

451

Fs,

452

Ftp,

453

Gcs,

454

Gdrive,

455

Ghac,

456

Github,

457

Gridfs,

458

Hdfs,

459

HdfsNative,

460

Http,

461

Huggingface,

462

Icloud,

463

Ipfs,

464

Ipmfs,

465

Koofr,

466

Libsql,

467

Memcached,

468

Memory,

469

MiniMoka,

470

Moka,

471

Mongodb,

472

Mysql,

473

Obs,

474

Onedrive,

475

Oss,

476

Pcloud,

477

Persy,

478

Postgresql,

479

Redb,

480

Redis,

481

Rocksdb,

482

S3,

483

Seafile,

484

Sftp,

485

Sled,

486

Sqlite,

487

Supabase,

488

Surrealdb,

489

Swift,

490

Tikv,

491

Upyun,

492

VercelArtifacts,

493

VercelBlob,

494

Webdav,

495

Webhdfs,

496

YandexDisk,

497

}

498

499

impl Scheme {

500

/// Get scheme from string representation

501

pub fn from_str(s: &str) -> Result<Self>;

502

503

/// Get string representation of scheme

504

pub fn into_static(self) -> &'static str;

505

}

506

```

507

508

**Usage Example:**

509

510

```rust

511

use opendal::Scheme;

512

513

// Check operator's backend service

514

let info = op.info();

515

match info.scheme() {

516

Scheme::S3 => println!("Using S3-compatible storage"),

517

Scheme::Fs => println!("Using local filesystem"),

518

Scheme::Redis => println!("Using Redis backend"),

519

_ => println!("Using other backend: {:?}", info.scheme()),

520

}

521

```