Custom serialisation for snapshot values.
Provides a protocol-based system for custom type serialisation, with built-in handlers for common edge cases like timestamps, UUIDs, and unstable values.
Custom serialisation for snapshot values. Provides a protocol-based system for custom type serialisation, with built-in handlers for common edge cases like timestamps, UUIDs, and unstable values.
(ensure-readable-edn text data context-data)Verify that text reads back as EDN equal to data.
Returns text unchanged. Throws ex-info when the text cannot be read back (e.g. it contains #object forms) or reads back as something different (e.g. a record, which prints as a plain map and so loses its identity). Either way the value needs a serialiser registered with still.serialize/register-serializer!
Verify that text reads back as EDN equal to data. Returns text unchanged. Throws ex-info when the text cannot be read back (e.g. it contains #object forms) or reads back as something different (e.g. a record, which prints as a plain map and so loses its identity). Either way the value needs a serialiser registered with still.serialize/register-serializer!
(format-value-for-source value)Format a value as source text for insertion into snap! calls.
For strings containing newlines when :multiline-strings? is enabled, produces a multi-line string literal with actual newlines instead of \n escapes. Falls back to pretty-print for all other values.
Throws ex-info when the formatted text cannot be read back, since inserting it would corrupt the source file.
Format a value as source text for insertion into snap! calls. For strings containing newlines when :multiline-strings? is enabled, produces a multi-line string literal with actual newlines instead of \n escapes. Falls back to pretty-print for all other values. Throws ex-info when the formatted text cannot be read back, since inserting it would corrupt the source file.
(pretty-print value)Pretty-print a value as EDN string for snapshot files.
Pretty-print a value as EDN string for snapshot files.
(register-serializer! the-type serializer-fn)Register a custom serialiser for a type.
The serialiser-fn should take a value and return EDN-serialisable data.
Example: (register-serializer! MyRecord (fn [r] {:type ::my-record :data (:data r)}))
Register a custom serialiser for a type.
The serialiser-fn should take a value and return EDN-serialisable data.
Example:
(register-serializer! MyRecord
(fn [r] {:type ::my-record :data (:data r)}))Protocol for custom snapshot serialisation.
Protocol for custom snapshot serialisation.
(serialize value)Serialise a value for snapshot storage. Returns EDN-serialisable data.
Serialise a value for snapshot storage. Returns EDN-serialisable data.
(serialize-value value)Serialise a value for snapshot storage.
Walks the entire data structure and applies custom serialisation where applicable. Returns EDN-serialisable data.
Serialise a value for snapshot storage. Walks the entire data structure and applies custom serialisation where applicable. Returns EDN-serialisable data.
(stable-value? value)Check if a value is stable (deterministic) for snapshot testing.
Returns true if the value contains no timestamps, UUIDs, or other unstable data.
Check if a value is stable (deterministic) for snapshot testing. Returns true if the value contains no timestamps, UUIDs, or other unstable data.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |