rust-async-patterns
تعلم أنماط Rust غير المتزامنة بسرعة
يمكن أن يكون Rust غير المتزامن صعب الهيكلية والتصحيح. تمنحك هذه المهارة أنماطًا واضحة لمهام Tokio والقنوات والتدفقات والأخطاء.
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "rust-async-patterns". اشرح كيفية تحديد التزامن لطلبات HTTP غير المتزامنة في Tokio.
النتيجة المتوقعة:
- Use a stream over URLs and apply buffer_unordered with a limit
- Collect results and handle errors per request
- Avoid unbounded spawning to protect memory and sockets
استخدام "rust-async-patterns". أرني كيفية التنسيق بين المهام غير المتزامنة باستخدام القنوات.
النتيجة المتوقعة:
- Use mpsc::channel for one-to-one communication between producer and consumer
- Use broadcast::channel when multiple consumers need the same message
- Use oneshot::channel when you need a single response from a spawned task
استخدام "rust-async-patterns". كيف أتعامل مع الأخطاء في كود Rust غير المتزامن بشكل صحيح؟
النتيجة المتوقعة:
- Use anyhow for application-level errors with context chaining
- Use thiserror for library code to create custom error types
- Wrap operations with timeout to prevent indefinite hanging
التدقيق الأمني
آمنPure educational documentation containing Rust async programming examples. All static findings are false positives: 'process spawn' refers to tokio::spawn for async task management (not command execution), 'backtick execution' refers to markdown code formatting, and 'weak cryptographic algorithm' refers to keywords in documentation fields. The skill contains no tool definitions, file access, network calls, or command execution capabilities.
عوامل الخطر
🌐 الوصول إلى الشبكة (6)
⚙️ الأوامر الخارجية (39)
درجة الجودة
ماذا يمكنك بناءه
بناء الخدمات المتزامنة
تطبيق أنماط مهيكلة لتنسيق المهام ومعالجة الأخطاء والإيقاف في خدمات Rust غير المتزامنة.
تصحيح توقف العمليات غير المتزامنة
استخدام إرشادات tracing والمشكلات الشائعة لتشخيص المهام المتوقفة وسوء استخدام الأقفال.
دراسة مفاهيم غير المتزامنة
تعلم Futures وawait والتدفقات والقنوات من خلال أمثلة قصيرة ومركزة.
جرّب هذه الموجهات
قدم مثالًا قصيرًا لبرنامج Tokio async main مع tracing واستدعاء async محاكي. اشرح كل خطوة بجملة واحدة.
اعرض نمطًا لتحديد مهام async المتزامنة لقائمة من URLs باستخدام Tokio أو futures streams.
اشرح نهج الإيقاف الناجح باستخدام CancellationToken وقناة إيقاف broadcast.
قدم تصميم سمة غير متزامنة لمستودع مع get وsave وdelete، ولاحظ استخدام كائنات السمات.
أفضل الممارسات
- Use tokio::select! to race futures safely
- Prefer channels for coordination over shared mutable state
- Instrument async tasks with tracing for observability
تجنب
- Calling blocking functions like std::thread::sleep in async code
- Holding mutex or rwlock guards across await points
- Spawning unlimited tasks without a concurrency limit
الأسئلة المتكررة
هل هذا متوافق مع إصدارات Tokio الحالية؟
هل يولد كود تطبيق كامل؟
هل يمكنني استخدامه في مستودع موجود؟
هل يصل إلى بياناتي أو يخزنها؟
ماذا لو كان كود غير المتزامن الخاص بي يتوقف؟
كيف يختلف هذا عن الأدلة العامة غير المتزامنة؟
تفاصيل المطور
المؤلف
wshobsonالترخيص
MIT
المستودع
https://github.com/wshobson/agents/tree/main/plugins/systems-programming/skills/rust-async-patternsمرجع
main
بنية الملفات
📄 SKILL.md