一键导入
rust-development
Rust development best practices for the Guts project - idiomatic code, error handling, async patterns, and commonware integration
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Rust development best practices for the Guts project - idiomatic code, error handling, async patterns, and commonware integration
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Git protocol implementation patterns using gitoxide for Guts repository operations
Infrastructure as Code patterns for deploying Guts nodes using Terraform, Docker, and Kubernetes
Peer-to-peer networking patterns using commonware for building decentralized Guts network
Comprehensive testing strategies for Guts including unit tests, integration tests, property-based testing, and fuzzing
| name | rust-development |
| description | Rust development best practices for the Guts project - idiomatic code, error handling, async patterns, and commonware integration |
You are developing a Rust project using commonware primitives for decentralized infrastructure.
thiserror for library errors, anyhow for applications# Always run before committing
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RepositoryError {
#[error("repository not found: {0}")]
NotFound(String),
#[error("permission denied for repository: {0}")]
PermissionDenied(String),
#[error("storage error: {0}")]
Storage(#[from] StorageError),
}
pub type Result<T> = std::result::Result<T, RepositoryError>;
Use Tokio for async runtime with structured concurrency:
use tokio::sync::{mpsc, oneshot};
// Prefer channels over shared state
pub struct Service {
tx: mpsc::Sender<Command>,
}
impl Service {
pub async fn query(&self, request: Request) -> Result<Response> {
let (tx, rx) = oneshot::channel();
self.tx.send(Command::Query { request, reply: tx }).await?;
rx.await?
}
}
// lib.rs - re-export public API
pub mod error;
pub mod types;
pub mod service;
pub use error::{Error, Result};
pub use types::*;
pub use service::Service;
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_feature() {
// Arrange
let service = Service::new().await;
// Act
let result = service.do_something().await;
// Assert
assert!(result.is_ok());
}
}
commonware-cryptography: Use for Ed25519 signaturescommonware-p2p: Use for peer-to-peer networkingcommonware-consensus: Use for BFT consensuscommonware-storage: Use for persistent storagecommonware-codec: Use for serializationuse commonware_cryptography::{Ed25519, Signer, Verifier};
pub struct Identity {
keypair: Ed25519,
}
impl Identity {
pub fn new() -> Self {
Self {
keypair: Ed25519::generate(),
}
}
pub fn sign(&self, message: &[u8]) -> Signature {
self.keypair.sign(message)
}
}
[package]
name = "guts-core"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
license = "MIT OR Apache-2.0"
description = "Core types and traits for Guts"
repository = "https://github.com/AbdelStark/guts"
keywords = ["decentralized", "git", "p2p"]
categories = ["development-tools"]
[dependencies]
# Use workspace dependencies
thiserror = { workspace = true }
tokio = { workspace = true }
[dev-dependencies]
tokio-test = { workspace = true }
[lints.rust]
unsafe_code = "deny"
missing_docs = "warn"
[lints.clippy]
all = "warn"
pedantic = "warn"
nursery = "warn"
Arc for shared ownership across async tasksbytes::Bytes for zero-copy networkingdashmap for concurrent hash mapsflamegraph before optimizing