Skip to content

Commit 982767f

Browse files
committed
Add details to readme
1 parent 5428931 commit 982767f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
1+
12
[![Build C# and Rust Project](https://github.com/gregyjames/CSharpRustInterop/actions/workflows/makefile.yml/badge.svg?branch=main)](https://github.com/gregyjames/CSharpRustInterop/actions/workflows/makefile.yml)
23

4+
5+
36
# CSharpRustInterop
7+
48
Some examples I found useful calling Rust from CSharp
9+
10+
11+
12+
# Examples
13+
14+
1. Writing to a memory mapped file by getting a `SafeMemoryMappedViewHandle` and passing its pointer to Rust.
15+
2. Passing a List of structs to Rust by using `CollectionMarshall` to read as a span and pinning the reference to the first element using `MemoryMarshal.GetReference`
16+
3. Passing a heap allocated class to Rust by using `GCHandle.Alloc(obj, GCHandleType.Pinned)` to acquire a handler to a fixed handler and using `AddrOfPinnedObject()` to retrieve the pointer to that object's memory location.
17+
18+
19+
# License
20+
MIT License
21+
22+
Copyright (c) 2025 Greg James
23+
24+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
25+
26+
The above copyright notice and this permission notice shall be included in all
27+
copies or substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)