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§
Structs§
- AddRepository
Request - Repository management messages
- Collection
Request - Create
Collection Request - Collection management messages
- Edit
Code Response - Response for EditCode RPC
- Empty
- Common messages
- Index
Files Request - Simple indexing messages
- Index
Response - List
Collections Response - List
Repositories Response - Query
Request - Query messages
- Query
Response - Remove
Repository Request - Repository
Request - Search
Result - Server
Info - Status
Response - Sync
Repository Request - UseBranch
Request - Validate
Edit Response - Response for ValidateEdit RPC