<p>For any new type to be implemented, three multimethods must be overriden, but which three depends on the native representation of the type.</p>
<p>If the native representation of the type is a primitive (whether or not other data beyond the primitive is associated with it, as e.g. a pointer), then <ahref="coffi.mem.html#var-primitive-type">primitive-type</a> must be overriden to return which primitive type it is serialized as, then <ahref="coffi.mem.html#var-serialize*">serialize*</a> and <ahref="coffi.mem.html#var-deserialize*">deserialize*</a> should be overriden.</p>
<p>If the native representation of the type is a composite type, like a union, struct, or array, then <ahref="coffi.mem.html#var-c-layout">c-layout</a> must be overriden to return the native layout of the type, and <ahref="coffi.mem.html#var-serialize-into">serialize-into</a> and <ahref="coffi.mem.html#var-deserialize-from">deserialize-from</a> should be overriden to allow marshaling values of the type into and out of memory segments.</p>
<p>When writing code that manipulates a segment, it’s best practice to use <ahref="coffi.mem.html#var-with-acquired">with-acquired</a> on the <ahref="coffi.mem.html#var-segment-session">segment-session</a> in order to ensure it won’t be released during its manipulation.</p></div></div><divclass="public anchor"id="var-add-close-action.21"><h3>add-close-action!</h3><divclass="usage"><code>(add-close-action! session action)</code></div><divclass="doc"><divclass="markdown"><p>Adds a 0-arity function to be run when the <code>session</code> closes.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L228">view source</a></div></div><divclass="public anchor"id="var-address-of"><h3>address-of</h3><divclass="usage"><code>(address-of addressable)</code></div><divclass="doc"><divclass="markdown"><p>Gets the address of a given segment.</p>
<p>This value can be used as an argument to functions which take a pointer.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L190">view source</a></div></div><divclass="public anchor"id="var-address.3F"><h3>address?</h3><divclass="usage"><code>(address? addr)</code></div><divclass="doc"><divclass="markdown"><p>Checks if an object is a memory address.</p>
<p><code>nil</code> is considered an address.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L202">view source</a></div></div><divclass="public anchor"id="var-align-of"><h3>align-of</h3><divclass="usage"><code>(align-of type)</code></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of the given <code>type</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L888">view source</a></div></div><divclass="public anchor"id="var-alloc"><h3>alloc</h3><divclass="usage"><code>(alloc size)</code><code>(alloc size session)</code><code>(alloc size alignment session)</code></div><divclass="doc"><divclass="markdown"><p>Allocates <code>size</code> bytes.</p>
<p>If a <code>session</code> is provided, the allocation will be reclaimed when it is closed.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L152">view source</a></div></div><divclass="public anchor"id="var-alloc-instance"><h3>alloc-instance</h3><divclass="usage"><code>(alloc-instance type)</code><code>(alloc-instance type session)</code></div><divclass="doc"><divclass="markdown"><p>Allocates a memory segment for the given <code>type</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L895">view source</a></div></div><divclass="public anchor"id="var-alloc-with"><h3>alloc-with</h3><divclass="usage"><code>(alloc-with allocator size)</code><code>(alloc-with allocator size alignment)</code></div><divclass="doc"><divclass="markdown"><p>Allocates <code>size</code> bytes using the <code>allocator</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L160">view source</a></div></div><divclass="public anchor"id="var-as-segment"><h3>as-segment</h3><divclass="usage"><code>(as-segment address size)</code><code>(as-segment address size session)</code></div><divclass="doc"><divclass="markdown"><p>Dereferences an <code>address</code> into a memory segment associated with the <code>session</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L234">view source</a></div></div><divclass="public anchor"id="var-big-endian"><h3>big-endian</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The big-endian <ahref="null">ByteOrder</a>.</p>
<p>See <ahref="coffi.mem.html#var-little-endian">little-endian</a>, <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L264">view source</a></div></div><divclass="public anchor"id="var-byte-layout"><h3>byte-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a byte in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L282">view source</a></div></div><divclass="public anchor"id="var-c-layout"><h3>c-layout</h3><h4class="type">multimethod</h4><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Gets the layout object for a given <code>type</code>.</p>
<p>Otherwise, it should return a <ahref="null">GroupLayout</a> for the given type.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L806">view source</a></div></div><divclass="public anchor"id="var-char-layout"><h3>char-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a c-sized char in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L298">view source</a></div></div><divclass="public anchor"id="var-clone-segment"><h3>clone-segment</h3><divclass="usage"><code>(clone-segment segment)</code><code>(clone-segment segment session)</code></div><divclass="doc"><divclass="markdown"><p>Clones the content of <code>segment</code> into a new segment of the same size.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L250">view source</a></div></div><divclass="public anchor"id="var-connected-scope"><h3>connected-scope</h3><h4class="deprecated">deprecated</h4><divclass="usage"><code>(connected-scope)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a new scope to reclaim all connected resources at once.</p>
<p>The scope may be shared across threads, and all resources created with it will be cleaned up at the same time, when all references have been collected.</p>
<p>This type of scope cannot be closed, and therefore should not be created in a <ahref="null">with-open</a> clause.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L93">view source</a></div></div><divclass="public anchor"id="var-connected-session"><h3>connected-session</h3><divclass="usage"><code>(connected-session)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a new memory session to reclaim all connected resources at once.</p>
<p>The session may be shared across threads, and all resources created with it will be cleaned up at the same time, when all references have been collected.</p>
<p>This type of session cannot be closed, and therefore should not be created in a <ahref="null">with-open</a> clause.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L82">view source</a></div></div><divclass="public anchor"id="var-copy-segment"><h3>copy-segment</h3><divclass="usage"><code>(copy-segment dest src)</code></div><divclass="doc"><divclass="markdown"><p>Copies the content to <code>dest</code> from <code>src</code>.</p>
<p>Returns <code>dest</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L241">view source</a></div></div><divclass="public anchor"id="var-defalias"><h3>defalias</h3><h4class="type">macro</h4><divclass="usage"><code>(defalias new-type aliased-type)</code></div><divclass="doc"><divclass="markdown"><p>Defines a type alias from <code>new-type</code> to <code>aliased-type</code>.</p>
<p>This creates needed serialization and deserialization implementations for the aliased type.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L1404">view source</a></div></div><divclass="public anchor"id="var-deserialize"><h3>deserialize</h3><divclass="usage"><code>(deserialize obj type)</code></div><divclass="doc"><divclass="markdown"><p>Deserializes an arbitrary type.</p>
<p>For types which have a primitive representation, this deserializes the primitive representation. For types which do not, this deserializes out of a segment.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L1176">view source</a></div></div><divclass="public anchor"id="var-deserialize*"><h3>deserialize*</h3><h4class="type">multimethod</h4><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Deserializes a primitive object into a Clojure data structure.</p>
<p>This is intended for use with types that are returned as a primitive but which need additional processing before they can be returned.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L1120">view source</a></div></div><divclass="public anchor"id="var-deserialize-from"><h3>deserialize-from</h3><h4class="type">multimethod</h4><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Deserializes the given segment into a Clojure data structure.</p>
<p>For types that serialize to primitives, a default implementation will deserialize the primitive before calling <ahref="coffi.mem.html#var-deserialize*">deserialize*</a>.</p>
<p>Implementations of this should be inside a <ahref="coffi.mem.html#var-with-acquired">with-acquired</a> block for the the <code>segment</code>’s session if they perform multiple memory operations.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L1053">view source</a></div></div><divclass="public anchor"id="var-double-alignment"><h3>double-alignment</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of a c-sized double.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L354">view source</a></div></div><divclass="public anchor"id="var-double-layout"><h3>double-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a c-sized double in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L306">view source</a></div></div><divclass="public anchor"id="var-double-size"><h3>double-size</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The size in bytes of a c-sized double.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L330">view source</a></div></div><divclass="public anchor"id="var-float-alignment"><h3>float-alignment</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of a c-sized float.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L350">view source</a></div></div><divclass="public anchor"id="var-float-layout"><h3>float-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a c-sized float in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L302">view source</a></div></div><divclass="public anchor"id="var-float-size"><h3>float-size</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The size in bytes of a c-sized float.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L326">view source</a></div></div><divclass="public anchor"id="var-global-scope"><h3>global-scope</h3><h4class="deprecated">deprecated</h4><divclass="usage"><code>(global-scope)</code></div><divclass="doc"><divclass="markdown"><p>Constructs the global scope, which will never reclaim its resources.</p>
<p>This scope may be shared across threads, but is intended mainly in cases where memory is allocated with <ahref="coffi.mem.html#var-alloc">alloc</a> but is either never freed or whose management is relinquished to a native library, such as when returned from a callback.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L114">view source</a></div></div><divclass="public anchor"id="var-global-session"><h3>global-session</h3><divclass="usage"><code>(global-session)</code></div><divclass="doc"><divclass="markdown"><p>Constructs the global session, which will never reclaim its resources.</p>
<p>This session may be shared across threads, but is intended mainly in cases where memory is allocated with <ahref="coffi.mem.html#var-alloc">alloc</a> but is either never freed or whose management is relinquished to a native library, such as when returned from a callback.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L104">view source</a></div></div><divclass="public anchor"id="var-int-alignment"><h3>int-alignment</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of a c-sized int.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L342">view source</a></div></div><divclass="public anchor"id="var-int-layout"><h3>int-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a c-sized int in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L290">view source</a></div></div><divclass="public anchor"id="var-int-size"><h3>int-size</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The size in bytes of a c-sized int.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L318">view source</a></div></div><divclass="public anchor"id="var-java-layout"><h3>java-layout</h3><divclass="usage"><code>(java-layout type)</code></div><divclass="doc"><divclass="markdown"><p>Gets the Java class to an argument of this type for a method handle.</p>
<p>If a type serializes to a primitive it returns return a Java primitive type. Otherwise, it returns <ahref="null">MemorySegment</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L873">view source</a></div></div><divclass="public anchor"id="var-java-prim-layout"><h3>java-prim-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Map of primitive type names to the Java types for a method handle.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L861">view source</a></div></div><divclass="public anchor"id="var-little-endian"><h3>little-endian</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The little-endian <ahref="null">ByteOrder</a>.</p>
<p>See <ahref="coffi.mem.html#var-big-endian">big-endian</a>, <ahref="coffi.mem.html#var-native-endian">native-endian</a></p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L270">view source</a></div></div><divclass="public anchor"id="var-long-alignment"><h3>long-alignment</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of a c-sized long.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L346">view source</a></div></div><divclass="public anchor"id="var-long-layout"><h3>long-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a c-sized long in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L294">view source</a></div></div><divclass="public anchor"id="var-long-size"><h3>long-size</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The size in bytes of a c-sized long.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L322">view source</a></div></div><divclass="public anchor"id="var-native-endian"><h3>native-endian</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">ByteOrder</a> for the native endianness of the current hardware.</p>
<p>See <ahref="coffi.mem.html#var-big-endian">big-endian</a>, <ahref="coffi.mem.html#var-little-endian">little-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L276">view source</a></div></div><divclass="public anchor"id="var-null.3F"><h3>null?</h3><divclass="usage"><code>(null? addr)</code></div><divclass="doc"><divclass="markdown"><p>Checks if a memory address is null.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L197">view source</a></div></div><divclass="public anchor"id="var-pointer-alignment"><h3>pointer-alignment</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of a c-sized pointer.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L358">view source</a></div></div><divclass="public anchor"id="var-pointer-layout"><h3>pointer-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a native pointer in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L310">view source</a></div></div><divclass="public anchor"id="var-pointer-size"><h3>pointer-size</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The size in bytes of a c-sized pointer.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L334">view source</a></div></div><divclass="public anchor"id="var-primitive-type"><h3>primitive-type</h3><h4class="type">multimethod</h4><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Gets the primitive type that is used to pass as an argument for the <code>type</code>.</p>
<p>This is for objects which are passed to native functions as primitive types, but which need additional logic to be performed during serialization and deserialization.</p>
<p>Implementations of this method should take into account that type arguments may not always be evaluated before passing to this function.</p>
<p>Returns nil for any type which does not have a primitive representation.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L753">view source</a></div></div><divclass="public anchor"id="var-primitive-types"><h3>primitive-types</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>A set of all primitive types.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L743">view source</a></div></div><divclass="public anchor"id="var-primitive.3F"><h3>primitive?</h3><divclass="usage"><code>(primitive? type)</code></div><divclass="doc"><divclass="markdown"><p>A predicate to determine if a given type is primitive.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L748">view source</a></div></div><divclass="public anchor"id="var-read-address"><h3>read-address</h3><divclass="usage"><code>(read-address segment)</code><code>(read-address segment offset)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">MemoryAddress</a> from the <code>segment</code>, at an optional <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L519">view source</a></div></div><divclass="public anchor"id="var-read-byte"><h3>read-byte</h3><divclass="usage"><code>(read-byte segment)</code><code>(read-byte segment offset)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">byte</a> from the <code>segment</code>, at an optional <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L362">view source</a></div></div><divclass="public anchor"id="var-read-char"><h3>read-char</h3><divclass="usage"><code>(read-char segment)</code><code>(read-char segment offset)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">char</a> from the <code>segment</code>, at an optional <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L453">view source</a></div></div><divclass="public anchor"id="var-read-double"><h3>read-double</h3><divclass="usage"><code>(read-double segment)</code><code>(read-double segment offset)</code><code>(read-double segment offset byte-order)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">double</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L494">view source</a></div></div><divclass="public anchor"id="var-read-float"><h3>read-float</h3><divclass="usage"><code>(read-float segment)</code><code>(read-float segment offset)</code><code>(read-float segment offset byte-order)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">float</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L469">view source</a></div></div><divclass="public anchor"id="var-read-int"><h3>read-int</h3><divclass="usage"><code>(read-int segment)</code><code>(read-int segment offset)</code><code>(read-int segment offset byte-order)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">int</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L403">view source</a></div></div><divclass="public anchor"id="var-read-long"><h3>read-long</h3><divclass="usage"><code>(read-long segment)</code><code>(read-long segment offset)</code><code>(read-long segment offset byte-order)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">long</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L428">view source</a></div></div><divclass="public anchor"id="var-read-short"><h3>read-short</h3><divclass="usage"><code>(read-short segment)</code><code>(read-short segment offset)</code><code>(read-short segment offset byte-order)</code></div><divclass="doc"><divclass="markdown"><p>Reads a <ahref="null">short</a> from the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L378">view source</a></div></div><divclass="public anchor"id="var-scope-allocator"><h3>scope-allocator</h3><h4class="deprecated">deprecated</h4><divclass="usage"><code>(scope-allocator scope)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a segment allocator from the given <code>scope</code>.</p>
<p>This is primarily used when working with unwrapped downcall functions. When a downcall function returns a non-primitive type, it must be provided with an allocator.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L133">view source</a></div></div><divclass="public anchor"id="var-segment-scope"><h3>segment-scope</h3><h4class="deprecated">deprecated</h4><divclass="usage"><code>(segment-scope segment)</code></div><divclass="doc"><divclass="markdown"><p>Gets the scope used to construct the <code>segment</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L147">view source</a></div></div><divclass="public anchor"id="var-segment-session"><h3>segment-session</h3><divclass="usage"><code>(segment-session segment)</code></div><divclass="doc"><divclass="markdown"><p>Gets the memory session used to construct the <code>segment</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L142">view source</a></div></div><divclass="public anchor"id="var-seq-of"><h3>seq-of</h3><divclass="usage"><code>(seq-of type segment)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a lazy sequence of <code>type</code> elements deserialized from <code>segment</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L1188">view source</a></div></div><divclass="public anchor"id="var-serialize"><h3>serialize</h3><divclass="usage"><code>(serialize obj type)</code><code>(serialize obj type session)</code></div><divclass="doc"><divclass="markdown"><p>Serializes an arbitrary type.</p>
<p>For types which have a primitive representation, this serializes into that representation. For types which do not, it allocates a new segment and serializes into that.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L1037">view source</a></div></div><divclass="public anchor"id="var-serialize*"><h3>serialize*</h3><h4class="type">multimethod</h4><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Constructs a serialized version of the <code>obj</code> and returns it.</p>
<p>Any new allocations made during the serialization should be tied to the given <code>session</code>, except in extenuating circumstances.</p>
<p>This method should only be implemented for types that serialize to primitives.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L902">view source</a></div></div><divclass="public anchor"id="var-serialize-into"><h3>serialize-into</h3><h4class="type">multimethod</h4><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>Writes a serialized version of the <code>obj</code> to the given <code>segment</code>.</p>
<p>Any new allocations made during the serialization should be tied to the given <code>session</code>, except in extenuating circumstances.</p>
<p>This method should be implemented for any type which does not override <ahref="coffi.mem.html#var-c-layout">c-layout</a>.</p>
<p>For any other type, this will serialize it as <ahref="coffi.mem.html#var-serialize*">serialize*</a> before writing the result value into the <code>segment</code>.</p>
<p>Implementations of this should be inside a <ahref="coffi.mem.html#var-with-acquired">with-acquired</a> block for the <code>session</code> if they perform multiple memory operations.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L963">view source</a></div></div><divclass="public anchor"id="var-session-allocator"><h3>session-allocator</h3><divclass="usage"><code>(session-allocator session)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a segment allocator from the given <code>session</code>.</p>
<p>This is primarily used when working with unwrapped downcall functions. When a downcall function returns a non-primitive type, it must be provided with an allocator.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L124">view source</a></div></div><divclass="public anchor"id="var-shared-scope"><h3>shared-scope</h3><h4class="deprecated">deprecated</h4><divclass="usage"><code>(shared-scope)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a new shared scope.</p>
<p>This scope can be shared across threads and memory allocated in it will only be cleaned up once every thread accessing the scope closes it.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L74">view source</a></div></div><divclass="public anchor"id="var-shared-session"><h3>shared-session</h3><divclass="usage"><code>(shared-session)</code><code>(shared-session cleaner)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a new shared memory session.</p>
<p>This session can be shared across threads and memory allocated in it will only be cleaned up once every thread accessing the session closes it.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L64">view source</a></div></div><divclass="public anchor"id="var-short-alignment"><h3>short-alignment</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The alignment in bytes of a c-sized short.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L338">view source</a></div></div><divclass="public anchor"id="var-short-layout"><h3>short-layout</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The <ahref="null">MemoryLayout</a> for a c-sized short in <ahref="coffi.mem.html#var-native-endian">native-endian</a><ahref="null">ByteOrder</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L286">view source</a></div></div><divclass="public anchor"id="var-short-size"><h3>short-size</h3><divclass="usage"></div><divclass="doc"><divclass="markdown"><p>The size in bytes of a c-sized short.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L314">view source</a></div></div><divclass="public anchor"id="var-size-of"><h3>size-of</h3><divclass="usage"><code>(size-of type)</code></div><divclass="doc"><divclass="markdown"><p>The size in bytes of the given <code>type</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L881">view source</a></div></div><divclass="public anchor"id="var-slice"><h3>slice</h3><divclass="usage"><code>(slice segment offset)</code><code>(slice segment offset size)</code></div><divclass="doc"><divclass="markdown"><p>Get a slice over the <code>segment</code> with the given <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L209">view source</a></div></div><divclass="public anchor"id="var-slice-into"><h3>slice-into</h3><divclass="usage"><code>(slice-into address segment)</code><code>(slice-into address segment size)</code></div><divclass="doc"><divclass="markdown"><p>Get a slice into the <code>segment</code> starting at the <code>address</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L216">view source</a></div></div><divclass="public anchor"id="var-slice-segments"><h3>slice-segments</h3><divclass="usage"><code>(slice-segments segment size)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a lazy seq of <code>size</code>-length memory segments, sliced from <code>segment</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L257">view source</a></div></div><divclass="public anchor"id="var-stack-scope"><h3>stack-scope</h3><h4class="deprecated">deprecated</h4><divclass="usage"><code>(stack-scope)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a new scope for use only in this thread.</p>
<p>The memory allocated within this scope is cheap to allocate, like a native stack.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L56">view source</a></div></div><divclass="public anchor"id="var-stack-session"><h3>stack-session</h3><divclass="usage"><code>(stack-session)</code><code>(stack-session cleaner)</code></div><divclass="doc"><divclass="markdown"><p>Constructs a new session for use only in this thread.</p>
<p>The memory allocated within this session is cheap to allocate, like a native stack.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L46">view source</a></div></div><divclass="public anchor"id="var-with-acquired"><h3>with-acquired</h3><h4class="type">macro</h4><divclass="usage"><code>(with-acquired sessions & body)</code></div><divclass="doc"><divclass="markdown"><p>Acquires one or more <code>sessions</code> until the <code>body</code> completes.</p>
<p>This is only necessary to do on shared sessions, however if you are operating on an arbitrary passed session, it is best practice to wrap code that interacts with it wrapped in this.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L167">view source</a></div></div><divclass="public anchor"id="var-with-offset"><h3>with-offset</h3><divclass="usage"><code>(with-offset address offset)</code></div><divclass="doc"><divclass="markdown"><p>Get a new address <code>offset</code> from the old <code>address</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L223">view source</a></div></div><divclass="public anchor"id="var-write-address"><h3>write-address</h3><divclass="usage"><code>(write-address segment value)</code><code>(write-address segment offset value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">MemoryAddress</a> to the <code>segment</code>, at an optional <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L717">view source</a></div></div><divclass="public anchor"id="var-write-byte"><h3>write-byte</h3><divclass="usage"><code>(write-byte segment value)</code><code>(write-byte segment offset value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">byte</a> to the <code>segment</code>, at an optional <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L535">view source</a></div></div><divclass="public anchor"id="var-write-char"><h3>write-char</h3><divclass="usage"><code>(write-char segment value)</code><code>(write-char segment offset value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">char</a> to the <code>segment</code>, at an optional <code>offset</code>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L637">view source</a></div></div><divclass="public anchor"id="var-write-double"><h3>write-double</h3><divclass="usage"><code>(write-double segment value)</code><code>(write-double segment offset value)</code><code>(write-double segment offset byte-order value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">double</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L689">view source</a></div></div><divclass="public anchor"id="var-write-float"><h3>write-float</h3><divclass="usage"><code>(write-float segment value)</code><code>(write-float segment offset value)</code><code>(write-float segment offset byte-order value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">float</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L661">view source</a></div></div><divclass="public anchor"id="var-write-int"><h3>write-int</h3><divclass="usage"><code>(write-int segment value)</code><code>(write-int segment offset value)</code><code>(write-int segment offset byte-order value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">int</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L581">view source</a></div></div><divclass="public anchor"id="var-write-long"><h3>write-long</h3><divclass="usage"><code>(write-long segment value)</code><code>(write-long segment offset value)</code><code>(write-long segment offset byte-order value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">long</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L609">view source</a></div></div><divclass="public anchor"id="var-write-short"><h3>write-short</h3><divclass="usage"><code>(write-short segment value)</code><code>(write-short segment offset value)</code><code>(write-short segment offset byte-order value)</code></div><divclass="doc"><divclass="markdown"><p>Writes a <ahref="null">short</a> to the <code>segment</code>, at an optional <code>offset</code>.</p>
<p>If <code>byte-order</code> is not provided, it defaults to <ahref="coffi.mem.html#var-native-endian">native-endian</a>.</p></div></div><divclass="src-link"><ahref="https://github.com/IGJoshua/coffi/blob/9d6051236550967a00151244e9e0c5630e2944b1/src/clj/coffi/mem.clj#L553">view source</a></div></div></div></body></html>