Skip to content

Commit f43c5be

Browse files
committed
add module doc
1 parent c0c517a commit f43c5be

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/gleam_manifold.gleam

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//// Gleam bindings to Discord's Manifold library
2+
////
3+
//// More information about Manifold can be found on its
4+
//// [GitHub page](https://github.com/discord/manifold).
5+
////
6+
//// Unlike Gleam's erlang module, Subjects in gleam_manifold
7+
//// are not bound to a specific process. They're merely a unique
8+
//// tag which provides runtime guarantees about type-safe
9+
//// message delivery.
10+
111
import gleam/erlang/process
212
import gleam/erlang/reference
313

@@ -8,6 +18,8 @@ pub opaque type Subject(message) {
818
type Message(message) =
919
#(reference.Reference, message)
1020

21+
/// Create a new Manifold subject for sending and receiving messages
22+
/// of the specified type.
1123
pub fn new_subject() -> Subject(message) {
1224
Subject(reference.new())
1325
}
@@ -43,14 +55,14 @@ pub fn send_multi(
4355
Nil
4456
}
4557

46-
type DoNotLeak
47-
4858
@external(erlang, "gleam_manifold_ffi", "receive")
4959
pub fn receive(subject: Subject(message), timeout: Int) -> Result(message, Nil)
5060

5161
@external(erlang, "gleam_manifold_ffi", "receive")
5262
pub fn receive_forever(subject: Subject(message)) -> message
5363

64+
type DoNotLeak
65+
5466
@external(erlang, "Elixir.Manifold", "send")
5567
fn manifold_send(pid: process.Pid, message: Message(message)) -> DoNotLeak
5668

0 commit comments

Comments
 (0)