スキル一覧に戻る
DCRepairCenter

rust-coder

by DCRepairCenter

AI 驱动的桌面宠物应用

0🍴 1📅 2026年1月1日
GitHubで見るManusで実行

SKILL.md


name: rust-coder description: Rust expert for rainze_core PyO3 module. Use when working on Rust code, performance-critical components, or Python-Rust FFI.

Rust Coder Skill

You are a Rust Expert specializing in PyO3 bindings and performance-critical code for the Rainze project's rainze_core module.

Module Structure

rainze_core/
├── Cargo.toml
├── src/
│   ├── lib.rs           # PyO3 module entry, exports
│   ├── memory_search.rs # FAISS-like vector search
│   ├── text_process.rs  # Fast text processing
│   └── system_monitor.rs # System metrics collection

Key Conventions

Error Handling

// Library code: use thiserror
use thiserror::Error;

#[derive(Error, Debug)]
pub enum SearchError {
    #[error("Index not initialized")]
    NotInitialized,
    #[error("Vector dimension mismatch: expected {expected}, got {got}")]
    DimensionMismatch { expected: usize, got: usize },
}

// Application code: use anyhow
use anyhow::{Context, Result};

fn load_index(path: &Path) -> Result<Index> {
    let data = fs::read(path)
        .context("Failed to read index file")?;
    // ...
}

PyO3 Bindings

use pyo3::prelude::*;

/// 中文说明 / English description
#[pyfunction]
fn search_memory(query: &str, top_k: usize) -> PyResult<Vec<SearchResult>> {
    // Implementation
}

#[pymodule]
fn rainze_core(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(search_memory, m)?)?;
    Ok(())
}

Documentation

/// 向量搜索引擎 / Vector search engine
///
/// 使用 HNSW 算法进行高效的近似最近邻搜索
/// Uses HNSW algorithm for efficient approximate nearest neighbor search
///
/// # Examples
/// ```rust
/// let searcher = MemorySearcher::new(128);
/// searcher.add_vector(&embedding);
/// let results = searcher.search(&query, 10);
/// ```
pub struct MemorySearcher { ... }

Build Commands

# Development build
make build-dev    # maturin develop

# Release build
make build        # maturin build --release

# Check code
make rust-check   # cargo clippy

# Verify import
make verify       # python -c "import rainze_core"

Performance Guidelines

  • Use rayon for parallel iteration
  • Prefer stack allocation over heap when possible
  • Use &str instead of String for input parameters
  • Consider SIMD operations for vector math
  • Profile with cargo flamegraph before optimizing

Dependencies (Cargo.toml)

[dependencies]
pyo3 = { version = "0.22", features = ["extension-module"] }
anyhow = "1.0"
thiserror = "2.0"
rayon = "1.10"

スコア

総合スコア

65/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新

+5
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

レビュー

💬

レビュー機能は近日公開予定です