Skip to content

Latest commit

 

History

History
100 lines (72 loc) · 2.46 KB

File metadata and controls

100 lines (72 loc) · 2.46 KB

Apache OpenDAL™ Swift Binding (WIP)

status: unreleased

A Swift binding for OpenDAL. Access storage services through one consistent API backed by the Rust core. Experimental — not suitable for production use.

We release the OpenDAL Swift binding independently of the opendal crate (Rust core). For updates and compatibility, use the Swift binding version instead of the opendal crate version.

Useful Links

Build

The Swift binding wraps the C binding. Build the C library before using the package:

cd bindings/swift
make build-c

To verify everything works:

make test

Installation

The package is not published to any registry. Reference it by local path in your project's Package.swift:

// swift-tools-version:5.7
import PackageDescription

let package = Package(
    name: "MyTool",
    dependencies: [
        .package(path: "/path/to/opendal/bindings/swift/OpenDAL"),
    ],
    targets: [
        .target(name: "MyTool", dependencies: [
            .product(name: "OpenDAL", package: "OpenDAL"),
        ]),
    ]
)

Quickstart

import OpenDAL

// Create an operator backed by the in-memory service.
let op = try Operator(scheme: "memory")

// Write bytes to a path.
var data = Data([1, 2, 3, 4])
try op.blockingWrite(&data, to: "/demo")

// Read them back.
let result = try op.blockingRead("/demo")
print(result)

Both blockingWrite and blockingRead throw OperatorError on failure.

For a real backend, pass the service scheme and options:

let op = try Operator(
    scheme: "s3",
    options: [
        "bucket": "my-bucket",
        "region": "us-east-1",
    ]
)

See the user guide for more examples, and Services for the full list of backends and their configuration keys.

Contributing

See CONTRIBUTING.md for how to set up the development environment and submit patches.

License and Trademarks

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.