Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 1.49 KB

README.md

File metadata and controls

68 lines (47 loc) · 1.49 KB

OpenDAL Swift Binding (WIP)

Using the Package

Build C Dependencies

The Swift binding depends on the C binding to OpenDAL. Before using this package, you need to build the C library first:

cd bindings/swift
make build-c

To check whether the package is ready to use, simply run the test:

make test

Add Dependency to Your Project

The package manifest is not located at the root directory of its repository. To use it, add the path of this package to the Package.swift manifest of your project:

// 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"),
    ]),
  ]
)

Example

The demo below shows how to write a key to the memory storage, and read it back:

import OpenDAL

// Create an operator with `memory` backend.
let op = try Operator(scheme: "memory")

// Write some data into path `/demo`.
let someData = Data([1, 2, 3, 4])
try op.blockingWrite(someData, to: "/demo")

// Read the data back.
let readData = try op.blockingRead("/demo")

// You can use the read data here.
print(readData!)

License

Apache v2.0