agentleFS
MicrosoftKnown publishermicrosoft/preflate-rs/dll/CLAUDE.md

preflate-rs / dll

CLAUDE.md38 starsChanged 9 months agoApache-2.0View on GitHub

C-compatible DLL for .NET interop. Exposes a streaming compress/decompress API as extern "C" functions. The version number is baked into the crate name (preflate_rs_0_7) for binary compatibility. flags encoding: - bits 0–4: Zstd compression level - bit 5: test_baseline - bit 6: verify Return value of compress_buffer: 0 = more output available, 1 = done, <0 = error. Magic numbers are validated on every call to catch dangling/wrong pointer bugs. - Uses #[unsafe(no_mangle)] on exported functions — the only place…

The file

We split this CLAUDE.md into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All other code in the crate remains safe Rust.

    line 69

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

dll (preflate_rs_0_7)

C-compatible DLL for .NET interop. Exposes a streaming compress/decompress API as extern "C" functions. The version number is baked into the crate name (preflate_rs_0_7) for binary compatibility.

Exported C API (src/unmanaged_api.rs)

Compression

void* create_compression_context(uint32_t flags);
void  free_compression_context(void* context);
int32_t compress_buffer(
    void*        context,
    const uint8_t* input,      size_t input_size,
    bool         input_complete,
    uint8_t*     output,       size_t output_size,
    size_t*      result_size,
    char*        error_string, size_t error_string_buffer_len
);
void get_compression_stats(void* context, /* stat out-params */);

flags encoding:

  • bits 0–4: Zstd compression level
  • bit 5: test_baseline
  • bit 6: verify

Return value of compress_buffer: 0 = more output available, 1 = done, <0 = error.

Decompression

void* create_decompression_context(uint32_t flags, size_t capacity);
void  free_decompression_context(void* context);
int32_t decompress_buffer(
    void*        context,
    const uint8_t* input,      size_t input_size,
    bool         input_complete,
    uint8_t*     output,       size_t output_size,
    size_t*      result_size,
    char*        error_string, size_t error_string_buffer_len
);

Internal Structs

struct CompressionContext {
    magic: u32,                   // MAGIC_COMPRESSION_CONTEXT = 0x4B3CFF2E
    internal: PreflateContainerProcessor,
    output_extra: VecDeque<u8>,   // buffers overflow when C buffer is too small
}
struct DecompressionContext {
    magic: u32,                   // MAGIC_DECOMPRESSION_CONTEXT = 0x053D2AB1
    internal: RecreateContainerProcessor,
    output_extra: VecDeque<u8>,
}

Magic numbers are validated on every call to catch dangling/wrong pointer bugs.

Safety Notes

  • Uses #[unsafe(no_mangle)] on exported functions — the only place in the workspace where unsafe appears (required for C FFI entry points).
  • catch_unwind_result() wraps every entry point to prevent panics crossing the FFI boundary.
  • All other code in the crate remains safe Rust.

Build Output

cdylib — produces preflate_rs_0_7.dll on Windows.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.