[nop] Housekeeping
This commit is contained in:
parent
bb178f66fc
commit
c0d1da1bb4
4 changed files with 27 additions and 23 deletions
|
|
@ -19,6 +19,8 @@ Notes:
|
||||||
|
|
||||||
\- [Peter Taoussanis](https://www.taoensso.com)
|
\- [Peter Taoussanis](https://www.taoensso.com)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# `v3.4.1` (2024-05-02)
|
# `v3.4.1` (2024-05-02)
|
||||||
|
|
||||||
> **Dep**: Nippy is [on Clojars](https://clojars.org/com.taoensso/nippy/versions/3.4.1).
|
> **Dep**: Nippy is [on Clojars](https://clojars.org/com.taoensso/nippy/versions/3.4.1).
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<a href="https://www.taoensso.com/clojure" title="More stuff by @ptaoussanis at www.taoensso.com"><img src="https://www.taoensso.com/open-source.png" alt="Taoensso open source" width="340"/></a>
|
<a href="https://www.taoensso.com/clojure" title="More stuff by @ptaoussanis at www.taoensso.com"><img src="https://www.taoensso.com/open-source.png" alt="Taoensso open source" width="340"/></a>
|
||||||
[**Documentation**](#documentation) | [Latest releases](#latest-releases) | [Get support][GitHub issues]
|
[**API**][cljdoc docs] | [**Wiki**][GitHub wiki] | [Latest releases](#latest-releases) | [Get support][GitHub issues]
|
||||||
|
|
||||||
# Nippy
|
# Nippy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
PersistentQueue PersistentTreeMap PersistentTreeSet PersistentList
|
PersistentQueue PersistentTreeMap PersistentTreeSet PersistentList
|
||||||
MapEntry LazySeq IRecord ISeq IType]))
|
MapEntry LazySeq IRecord ISeq IType]))
|
||||||
|
|
||||||
(enc/assert-min-encore-version [3 112 0])
|
(enc/assert-min-encore-version [3 127 0])
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(set! *unchecked-math* :warn-on-boxed)
|
(set! *unchecked-math* :warn-on-boxed)
|
||||||
|
|
@ -300,14 +300,14 @@
|
||||||
- `payload-spec` examples:
|
- `payload-spec` examples:
|
||||||
- nil ; No spec available (e.g. unpredictable payload)
|
- nil ; No spec available (e.g. unpredictable payload)
|
||||||
- [] ; Type has no payload
|
- [] ; Type has no payload
|
||||||
- [[:bytes 4]] ; Type has a payload of exactly 4 bytes
|
- [[:bytes 4]] ; Type has payload of exactly 4 bytes
|
||||||
- [[:bytes 2] [:elements 2]] ; Type has a payload of exactly 2 bytes, then
|
- [[:bytes 2] [:elements 2]] ; Type has payload of exactly 2 bytes,
|
||||||
; 2 elements
|
; followed by 2 elements
|
||||||
|
|
||||||
- [[:bytes {:read 2}]
|
- [[:bytes {:read 2}]
|
||||||
[:elements {:read 4 :multiplier 2 :unsigned? true}]]
|
[:elements {:read 4 :multiplier 2 :unsigned? true}]]
|
||||||
|
|
||||||
; Type has payload of <short-count> bytes, then
|
; Type has payload of <short-count> bytes, followed by
|
||||||
; <unsigned-int-count>*2 (multiplier) elements
|
; <unsigned-int-count>*2 (multiplier) elements
|
||||||
|
|
||||||
Note that `payload-spec` can be handy for skipping over items in
|
Note that `payload-spec` can be handy for skipping over items in
|
||||||
|
|
@ -1254,7 +1254,7 @@
|
||||||
- :compressor nil
|
- :compressor nil
|
||||||
- :encryptor nil
|
- :encryptor nil
|
||||||
- :no-header? true"
|
- :no-header? true"
|
||||||
[x]
|
^bytes [x]
|
||||||
(let [baos (ByteArrayOutputStream. 64)
|
(let [baos (ByteArrayOutputStream. 64)
|
||||||
dos (DataOutputStream. baos)]
|
dos (DataOutputStream. baos)]
|
||||||
(with-cache (-freeze-with-meta! x dos))
|
(with-cache (-freeze-with-meta! x dos))
|
||||||
|
|
@ -1263,8 +1263,10 @@
|
||||||
(defn freeze
|
(defn freeze
|
||||||
"Serializes arg (any Clojure data type) to a byte array.
|
"Serializes arg (any Clojure data type) to a byte array.
|
||||||
To freeze custom types, extend the Clojure reader or see `extend-freeze`."
|
To freeze custom types, extend the Clojure reader or see `extend-freeze`."
|
||||||
([x] (freeze x nil))
|
(^bytes [x] (freeze x nil))
|
||||||
([x {:as opts
|
(^bytes
|
||||||
|
[x
|
||||||
|
{:as opts
|
||||||
:keys [compressor encryptor password serializable-allowlist incl-metadata?]
|
:keys [compressor encryptor password serializable-allowlist incl-metadata?]
|
||||||
:or {compressor :auto
|
:or {compressor :auto
|
||||||
encryptor aes128-gcm-encryptor}}]
|
encryptor aes128-gcm-encryptor}}]
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
(do
|
(do
|
||||||
(defmacro with-freeze-opts [opts & body] `(binding [*freeze-opts* ~opts ] ~@body))
|
(defmacro with-freeze-opts [opts & body] `(binding [*freeze-opts* ~opts ] ~@body))
|
||||||
(defmacro with-freeze-opts+ [opts & body] `(binding [*freeze-opts* (enc/fast-merge *freeze-opts* ~opts)] ~@body))
|
(defmacro with-freeze-opts+ [opts & body] `(binding [*freeze-opts* (enc/merge *freeze-opts* ~opts)] ~@body))
|
||||||
(defmacro with-thaw-opts [opts & body] `(binding [*thaw-opts* ~opts ] ~@body))
|
(defmacro with-thaw-opts [opts & body] `(binding [*thaw-opts* ~opts ] ~@body))
|
||||||
(defmacro with-thaw-opts+ [opts & body] `(binding [*thaw-opts* (enc/fast-merge *thaw-opts* ~opts)] ~@body)))
|
(defmacro with-thaw-opts+ [opts & body] `(binding [*thaw-opts* (enc/merge *thaw-opts* ~opts)] ~@body)))
|
||||||
|
|
||||||
(deftype WrappedForFreezing [val opts])
|
(deftype WrappedForFreezing [val opts])
|
||||||
(defn wrapped-for-freezing? [x] (instance? WrappedForFreezing x))
|
(defn wrapped-for-freezing? [x] (instance? WrappedForFreezing x))
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
See also `tools/freeze`."
|
See also `tools/freeze`."
|
||||||
([x ] (wrap-for-freezing x nil))
|
([x ] (wrap-for-freezing x nil))
|
||||||
([x wrap-opts]
|
([x wrap-opts]
|
||||||
(let [captured-opts (enc/fast-merge *freeze-opts* wrap-opts)] ; wrap > dynamic
|
(let [captured-opts (enc/merge *freeze-opts* wrap-opts)] ; wrap > dynamic
|
||||||
(if (instance? WrappedForFreezing x)
|
(if (instance? WrappedForFreezing x)
|
||||||
(let [^WrappedForFreezing x x]
|
(let [^WrappedForFreezing x x]
|
||||||
(if (= (.-opts x) captured-opts)
|
(if (= (.-opts x) captured-opts)
|
||||||
|
|
@ -47,11 +47,11 @@
|
||||||
([x ] (freeze x nil))
|
([x ] (freeze x nil))
|
||||||
([x default-opts]
|
([x default-opts]
|
||||||
(let [default-opts (get default-opts :default-opts default-opts) ; Back compatibility
|
(let [default-opts (get default-opts :default-opts default-opts) ; Back compatibility
|
||||||
active-opts (enc/fast-merge default-opts *freeze-opts*)] ; dynamic > default
|
active-opts (enc/merge default-opts *freeze-opts*)] ; dynamic > default
|
||||||
|
|
||||||
(if (instance? WrappedForFreezing x)
|
(if (instance? WrappedForFreezing x)
|
||||||
(let [^WrappedForFreezing x x]
|
(let [^WrappedForFreezing x x]
|
||||||
(nippy/freeze (.-val x) (enc/fast-merge active-opts (.-opts x)))) ; captured > active!
|
(nippy/freeze (.-val x) (enc/merge active-opts (.-opts x)))) ; captured > active!
|
||||||
(nippy/freeze x active-opts)))))
|
(nippy/freeze x active-opts)))))
|
||||||
|
|
||||||
(defn thaw
|
(defn thaw
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
([ba ] (thaw ba nil))
|
([ba ] (thaw ba nil))
|
||||||
([ba default-opts]
|
([ba default-opts]
|
||||||
(let [default-opts (get default-opts :default-opts default-opts) ; Back compatibility
|
(let [default-opts (get default-opts :default-opts default-opts) ; Back compatibility
|
||||||
active-opts (enc/fast-merge default-opts *thaw-opts*)] ; dynamic > default
|
active-opts (enc/merge default-opts *thaw-opts*)] ; dynamic > default
|
||||||
|
|
||||||
(nippy/thaw ba active-opts))))
|
(nippy/thaw ba active-opts))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue