How to use Rust-backed filesystems

Replace a local or S3 filesystem with its fsspec-rs equivalent, configure an S3-compatible endpoint, or choose a read cache.

Select a backend by protocol

Use fsspec to construct a filesystem when an application accepts a protocol:

import fsspec
import fsspec_rs

local = fsspec.filesystem("file-rs", auto_mkdir=True)
s3 = fsspec.filesystem("s3-rs", bucket="reports", region="us-east-1")

Use direct classes when an application accepts an AbstractFileSystem instance:

from fsspec_rs import LocalFileSystem, S3FileSystem

local = LocalFileSystem(auto_mkdir=True)
s3 = S3FileSystem(bucket="reports", region="us-east-1")

Use fsspec URLs

Import fsspec_rs before resolving a protocol in environments that do not discover package entry points automatically:

import fsspec
import fsspec_rs

with fsspec.open("file-rs:///tmp/report.txt", "wb") as file:
    file.write(b"complete\n")

with fsspec.open(
    "s3-rs://reports/2026/summary.txt",
    "rb",
    region="us-east-1",
) as file:
    summary = file.read()

Keep file, local, memory, and s3 URLs when you want the existing Python implementations. Use the -rs protocols to select the Rust-backed implementations explicitly.

Configure an S3-compatible service

Pass the service’s endpoint and credentials to S3FileSystem:

from fsspec_rs import S3FileSystem

fs = S3FileSystem(
    bucket="warehouse",
    endpoint_url="http://localhost:9000",
    region="us-east-1",
    key="minioadmin",
    secret="minioadmin",
)

Use anon=True for anonymous access. For AWS, omit explicit credentials to use AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and optional AWS_SESSION_TOKEN. Without static credentials, the backend uses its instance-metadata provider.

Set transport limits through client_options:

fs = S3FileSystem(
    bucket="reports",
    client_options={"connect_timeout": 2, "request_timeout": 15, "max_retries": 3},
)

Pass explicit key/secret pairs when accessing multiple credential contexts. See S3 configuration for precedence, cache behavior and retry limits.

Limit memory use for S3 reads

Choose an explicit cache strategy when opening large objects. Omitting cache_type eagerly reads the whole S3 object:

with fs.open(
    "tables/orders.parquet",
    "rb",
    cache_type="block",
    block_size=8 * 1024 * 1024,
) as file:
    header = file.read(64 * 1024)

The Python wrapper uses the Rust default of 32 cached blocks; it does not forward max_blocks. Choose none for direct range fetches, readahead for sequential access, or block for repeated random access. Use all only when you want to fetch the whole object on first read. See the filesystem reference for cache behavior and supported operations.

Check a filesystem as a records store

Applications that keep one file per record, such as fsspec.get_mapper stores, need atomic replacement, durable writes, complete listings, and FileNotFoundError for missing records. fsspec_rs.testing.records checks these guarantees for any fsspec URL. Import its tests into a test module and define a unique empty root and its storage options:

import pytest

from fsspec_rs.testing.records import *  # noqa: F403


@pytest.fixture
def records_url(tmp_path):
    return f"file-rs://{tmp_path}/records"


@pytest.fixture
def records_storage_options():
    return {"auto_mkdir": True}

Storage options must be JSON-serializable, because one test reopens the store in a separate process. file-rs, s3-rs, and s3fs pass. fsspec’s file protocol fails the replacement test because it writes directly to the target.

Check create-if-absent on a storage deployment

Choose a scratch prefix where the test may create and delete manifest objects. Run the reusable suite against each AWS bucket configuration, S3-compatible server, and NFS mount used for publication:

export FSSPEC_CREATE_TEST_URL='s3-rs://test-bucket/create-checks'
export FSSPEC_CREATE_TEST_OPTIONS='{"region": "us-east-1"}'
pytest fsspec_rs/tests/test_create_conformance.py -k deployment

For an on-prem store, add endpoint_url and the required credential settings to FSSPEC_CREATE_TEST_OPTIONS, or use your existing credential configuration. For NFS, use a file-rs:///mount/create-checks URL and FSSPEC_CREATE_TEST_OPTIONS='{"auto_mkdir": true}'.

The suite creates a unique subdirectory, checks competing creates, verifies complete binary and empty objects through a second client, and removes its test files. Local directories may remain empty. To reuse it in another repository, import fsspec_rs.testing.create tests and supply create_url and create_storage_options fixtures with a unique scratch prefix.

Record the package version, store version, endpoint configuration and mount options with the results. Run failure-injection checks in your deployment for lost acknowledgements and interrupted writes; the local protocol tests in test_create_recovery.py exercise those client paths without certifying a real store. For NFS, also verify visibility and competing publication from separate hosts. The in-process local, memory and simulated S3 results are not AWS, on-prem or NFS certification.