async-drop

Enforce safe asynchronous cleanup for Rust resources with AsyncDropGuard.

2.3k|168|Updated Sep 12, 2015
One-click install
npx skills add https://github.com/cryfs/cryfs --skill async-drop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: async-drop
Source: https://github.com/cryfs/cryfs/tree/main/.claude/skills/async-drop
Command: npx skills add https://github.com/cryfs/cryfs --skill async-drop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AsyncDrop patterns enforce safe, asynchronous cleanup for resources in Rust, addressing the need to properly finalize resources that require async teardown, preventing leaks and ensuring deterministic shutdown.

Core Features & Use Cases

  • AsyncDropGuard wraps values to require explicit asynchronous cleanup via async_drop().
  • AsyncDrop trait implementations provide per-resource cleanup logic.
  • Patterns for composition and ownership: delegating to member AsyncDrops, with_async_drop_2 macro, and sharing via AsyncDropArc.
  • Concurrency-friendly cleanup, including parallel drops for independent members and safe transfer of guard ownership.

Quick Start

Use the AsyncDrop pattern to ensure a resource is cleaned up asynchronously by wrapping it in AsyncDropGuard and invoking async_drop() when done.

Frequently Asked Questions about async-drop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement async cleanup for resources in Rust?

Async cleanup in Rust is implemented by wrapping values in AsyncDropGuard and invoking async_drop() to enforce safe finalization. This pattern prevents leaks by ensuring deterministic shutdown across all exit paths.

How does AsyncDropGuard handle ownership transfer in async Rust?

AsyncDropGuard handles ownership transfer by safely wrapping values to require explicit async cleanup. It supports concurrent and shared cleanup utilities, including safe transfer of guard ownership across async boundaries.

What is the best way to automate async cleanup for multiple struct members in Rust?

Automating async cleanup for multiple struct members is best handled using the with_async_drop_2 macro and delegating to member AsyncDrops. This supports composition and enables parallel drops for independent members.

When do I need an AsyncDrop trait implementation in Rust?

An AsyncDrop trait implementation is needed when a Rust resource requires explicit asynchronous teardown logic. It provides per-resource cleanup to properly finalize resources, preventing leaks that standard synchronous Drop cannot address.

Can I share an async cleanup guard across concurrent tasks in Rust?

Sharing an async cleanup guard across concurrent Rust tasks is supported using AsyncDropArc. This provides concurrency-friendly cleanup, including parallel drops for independent members and safe transfer of guard ownership within shared utilities.

Does async cleanup in Rust work with standard ownership and borrowing rules?

Async cleanup in Rust works with standard ownership rules by enforcing explicit asynchronous teardown via AsyncDropGuard. Composition patterns allow delegating to member AsyncDrops while maintaining safe concurrent cleanup across ownership scenarios.