Skip to main content

Module ffi

Module ffi 

Source
Expand description

Minimal C ABI for Swift interop.

§Handle-based API

All functions operate on an opaque FsHandle obtained from fs_create. The caller must eventually call fs_destroy to free the handle.

§Buffer ownership

  • Buffers passed into Rust (e.g. data in fs_write_file) are borrowed for the duration of the call. The caller retains ownership.
  • Buffers returned from Rust (e.g. fs_list_root JSON string) are allocated by Rust. The caller must free them with fs_free_string.
  • For fs_read_file, the caller provides the output buffer and its capacity.

Structs§

FsHandle
Opaque handle to a FilesystemCore instance.

Functions§

fs_create
Create a new in-memory filesystem handle.
fs_create_device
Create a filesystem handle backed by a raw block device (e.g. /dev/xvdf).
fs_create_dir
Create a directory at the given path.
fs_create_disk
Create a filesystem handle backed by a file on disk.
fs_create_file
Create a file at the given path.
fs_destroy
Destroy a filesystem handle and free all associated resources.
fs_free_string
Free a string previously returned by fs_list_root.
fs_init_filesystem
Initialize a new filesystem on the block store.
fs_list_dir
List a directory at the given path. Returns a JSON string.
fs_list_root
List the root directory. Returns a JSON string.
fs_open
Open / mount an existing filesystem from the block store.
fs_read_file
Read file data into a caller-provided buffer.
fs_remove_file
Remove a file (or empty directory) at the given path.
fs_rename
Rename a file or directory. Both paths must share the same parent directory.
fs_sync
Sync / flush the filesystem.
fs_write_file
Write data to a file at the given path.