Skip to content

Add dir() method to Rust KvsBuilder for API parity with C++ #222

@kgraeper

Description

@kgraeper

Add dir() method to Rust KvsBuilder for API parity with C++

Component: @score_persistency Rust bindings (rust_kvs)
Priority: Medium
Type: Feature Gap / API Enhancement


Summary

The C++ KvsBuilder API provides a dir(std::string&&) method to set the storage directory, but the Rust KvsBuilder does not expose an equivalent method. This creates API inconsistency between languages and forces Rust users to use the more verbose backend configuration approach.

Current Behavior

C++ API (available):

auto kvs = KvsBuilder(instance_id)
    .dir("./storage")
    .need_kvs_flag(true)
    .build();

Rust API (workaround required):

// No .dir() method available - must configure backend explicitly
let backend = JsonBackendBuilder::new()
    .working_dir(PathBuf::from("./storage"))
    .build();

let kvs = KvsBuilder::new(instance_id)
    .backend(Box::new(backend))
    .kvs_load(KvsLoad::Optional)
    .build()?;

Expected Behavior
Rust KvsBuilder should provide a dir() method for API consistency:

let kvs = KvsBuilder::new(instance_id)
    .dir("./storage")  // ← Should work
    .kvs_load(KvsLoad::Optional)
    .build()?;

References
C++ API: src/cpp/src/kvsbuilder.hpp:90
Rust implementation: src/rust/rust_kvs/src/kvs_builder.rs:58

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions