Crate vectordb_client

Source
Expand description

§vectordb-client

Client library for interacting with the VectorDB semantic code search service. This crate provides a gRPC client for connecting to the VectorDB server and performing operations such as indexing code, searching, repository management, and semantic code editing.

§Usage

use vectordb_client::VectorDBClient;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    // Create a client with default configuration (localhost:50051)
    let mut client = VectorDBClient::default().await?;
     
    // Get server info
    let server_info = client.get_server_info().await?;
    println!("Connected to server version: {}", server_info.version);
     
    // List collections
    let collections = client.list_collections().await?;
    println!("Available collections:");
    for collection in collections.collections {
        println!("  - {}", collection);
    }
     
    Ok(())
}

§Code Editing Features

The client supports semantic code editing with both line-based and element-based targeting:

use vectordb_client::VectorDBClient;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut client = VectorDBClient::default().await?;
     
    // Edit a function by element name
    let result = client.edit_file_by_element(
        "src/main.rs".to_string(),
        "function:process_data".to_string(),
        "fn process_data(input: &str) -> String {\n    format!(\"processed: {}\", input)\n}".to_string(),
        true,  // format code
        false, // don't update references
    ).await?;
     
    if result.success {
        println!("Edit applied successfully");
    } else {
        println!("Edit failed: {}", result.error_message.unwrap_or_default());
    }
     
    Ok(())
}

Re-exports§

pub use client::grpc::VectorDBClient;
pub use config::ClientConfig;
pub use error::ClientError;
pub use error::Result;
pub use client::editing::EditFileTarget;
pub use client::editing::EditFileOptions;
pub use client::editing::ValidationSeverity;
pub use client::editing::ValidationIssueInfo;

Modules§

client
Client module for the VectorDB service.
config
error

Structs§

AddRepositoryRequest
Repository management messages
CollectionRequest
CreateCollectionRequest
Collection management messages
EditCodeResponse
Response for EditCode RPC
Empty
Common messages
IndexFilesRequest
Simple indexing messages
IndexResponse
ListCollectionsResponse
ListRepositoriesResponse
QueryRequest
Query messages
QueryResponse
RemoveRepositoryRequest
RepositoryRequest
SearchResult
ServerInfo
StatusResponse
SyncRepositoryRequest
UseBranchRequest
ValidateEditResponse
Response for ValidateEdit RPC