Skip to content
This repository was archived by the owner on Dec 13, 2020. It is now read-only.

Commit 62a133c

Browse files
committed
Fixed readme and release
1 parent be33299 commit 62a133c

2 files changed

Lines changed: 50 additions & 51 deletions

File tree

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Contents
5454
* [Changelog](#changelog)
5555

5656
<a name="getting-started"></a> Getting started
57-
------------------------------------------
57+
----------------------------------------------
5858

5959
The library is published to the Maven central, so you can just add the following line
6060
to your `build.sbt` file in order to use the core library:
@@ -99,7 +99,7 @@ available later.
9999
[Jawn]: https://github.com/non/jawn
100100

101101
<a name="serialization-mechanism"></a> Serialization mechanism
102-
----------------------------------------------------------
102+
--------------------------------------------------------------
103103

104104
picopickle uses the pretty standard typeclass approach where the way the type is serialized
105105
or deserialized is defined through implicit objects (called `Reader[T]` and `Writer[T]` in picopickle)
@@ -136,7 +136,7 @@ picopickle also supports default values and variable arguments in case classes a
136136
or sealed trait descendants with a bit of custom macros.
137137

138138
<a name="usage"></a> Usage
139-
-----
139+
--------------------------
140140

141141
### <a name="basic-usage"></a> Basic usage
142142

@@ -546,7 +546,7 @@ val s: backend.BString = backend.makeString("hello world")
546546
These implicit methods are somewhat more convenient than `make*` functions.
547547

548548
<a name="converters"></a> Converters
549-
--------------------------------
549+
------------------------------------
550550

551551
Low-level conversions, however, may be overly verbose to write. picopickle provides a declarative way of
552552
defining how the backend representation should be translated to the desired Scala objects and vice versa.
@@ -677,7 +677,7 @@ val optionStringConv: Converter.Id[Option[String]] = value[Option[String]]
677677
You can find more on converters in their Scaladoc section (**TODO**).
678678

679679
<a name="supported-types"></a> Supported types
680-
------------------------------------------
680+
----------------------------------------------
681681

682682
By default picopickle provides a lot of serializers for various types which do their
683683
best to represent their respective types in the serialized form as close as possible.
@@ -1141,7 +1141,7 @@ as a `BNumber` if it can be represented precisely in `Double` as a `BString` oth
11411141
This trait is useful e.g. when writing a JSON-based backend.
11421142

11431143
<a name="official-backends"></a> Official backends
1144-
----------------------------------------------
1144+
--------------------------------------------------
11451145

11461146
### <a name="collections-pickler"></a> Collections pickler
11471147

@@ -1295,7 +1295,7 @@ it serializes `BValue` as `BValue`, `BString` as `BString`, `BInt64` as `BInt64`
12951295
[bson]: http://mongodb.github.io/mongo-java-driver/3.0/bson/
12961296

12971297
<a name="error-handling"></a> Error handling
1298-
----------------------------------------
1298+
--------------------------------------------
12991299

13001300
While serialization is straightforward and should never fail (if it does, it is most likely a bug in the library
13011301
or in some `Writer` implementation), deserialization is prone to errors because the serialized representation usually
@@ -1384,7 +1384,7 @@ serialization methods, like Jawn's `tryReadString()`.
13841384

13851385

13861386
<a name="limitations"></a> Limitations
1387-
----------------------------------
1387+
--------------------------------------
13881388

13891389
picopickle does not support serializing `Any` in any form because it relies on the static knowledge of
13901390
types being serialized. However, its design, as far as I can tell, in principle does not disallow writing
@@ -1434,16 +1434,17 @@ object Serializers {
14341434

14351435

14361436
<a name="plans"></a> Plans
1437-
----------------------
1437+
--------------------------
14381438

14391439
* Consider adding support for more types
14401440
* Consider adding more converters (e.g. for tuples)
1441+
* Add proper support for error handling in conversions
14411442
* Add more tests
14421443
* Add more documentation
14431444

14441445

14451446
<a name="changelog"></a> Changelog
1446-
------------------------------
1447+
----------------------------------
14471448

14481449
### 0.2.0
14491450

notes/0.2.0.markdown

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
11
This release contains a lot of changes and new features.
22

3-
* Updated shapeless to 2.3.3, jawn to 0.8.8, scala to 2.11.7.
3+
### Updated shapeless to 2.3.3, jawn to 0.8.8, scala to 2.11.7.
44

5-
In particular, updating shapeless allowed using picopickle with case classes with variable arguments.
5+
In particular, updating shapeless allowed using picopickle with case classes with variable arguments.
66

7-
* Improved reader interface - added `readOrElse` method and changed existing code to depend on it.
7+
### Improved reader interface - added `readOrElse` method and changed existing code to depend on it.
88

9-
`readOrElse` is borrowed from `PartialFunction` trait where it is called `applyOrElse`. It is an
10-
important method for optimization because it allows checking whether a function (reader) can be
11-
applied to a value and apply it to this value at the same time. Now `Reader` trait has this method
12-
and it is defined and used correctly by the built-in `Reader` combinators, in particular,
13-
for error checks.
9+
`readOrElse` is borrowed from `PartialFunction` trait where it is called `applyOrElse`. It is an
10+
important method for optimization because it allows checking whether a function (reader) can be
11+
applied to a value and apply it to this value at the same time. Now `Reader` trait has this method
12+
and it is defined and used correctly by the built-in `Reader` combinators, in particular,
13+
for error checks.
1414

15-
* Added proper error handling.
15+
### Added proper error handling.
1616

17-
While writing data to backend representation is usually an error-free operation (if there is a writer
18-
for some type, it should handle all values of this type), reading data from the backend representation
19-
is a source of errors. This happens because the backend representation has much weaker typing guarantees
20-
than Scala code and can't correspond directly to Scala types.
21-
22-
Previously picopickle didn't provide any special error handling. If the backend value couldn't be
23-
deserialized, picopickle would throw some obscure `MatchError` or `IllegalArgumentException`. Since
24-
0.2.0 picopickle has a proper exception system, and if a read error occurs, the exception would contain
25-
much more information about what was expected and what was actually found. You can find more on it
26-
in [Readme][readme-error-handling].
27-
28-
* Added new BSON-based backend.
17+
While writing data to backend representation is usually an error-free operation (if there is a writer
18+
for some type, it should handle all values of this type), reading data from the backend representation
19+
is a source of errors. This happens because the backend representation has much weaker typing guarantees
20+
than Scala code and can't correspond directly to Scala types.
2921

30-
A new officially supported backend has been added. It uses [MongoDB BSON][mongodb-bson] data types
31-
as the backend representation.
32-
33-
With this backend it is possible to use picopickle for serialization using the official Mongo drivers.
22+
Previously picopickle didn't provide any special error handling. If the backend value couldn't be
23+
deserialized, picopickle would throw some obscure `MatchError` or `IllegalArgumentException`. Since
24+
0.2.0 picopickle has a proper exception system, and if a read error occurs, the exception would contain
25+
much more information about what was expected and what was actually found. You can find more on it
26+
in [Readme][readme-error-handling].
3427

35-
It also serves as an example extended backend implementation with more types than the basic backend
36-
supports.
28+
### Added new BSON-based backend.
3729

38-
* Added support for changing STH discriminator key on per-STH basis.
30+
A new officially supported backend has been added. It uses [MongoDB BSON][mongodb-bson] data types
31+
as the backend representation.
3932

40-
It is now possible to change sealed trait hierarchy discriminator key for each sealed trait separately:
41-
42-
```scala
43-
@discriminator("status") sealed trait Root
44-
case object Stopped extends Root
45-
case class Running(name: String) extends Root
46-
47-
writeString[Root](Stopped) shouldEqual """{"status":"Stopped"}"""
48-
writeString[Root](Running("me")) shouldEqual """{"status":"Running","name":"me"}"""
49-
```
50-
51-
This allows even more flexibility in defining serialization formats, especially when matching some
52-
existing interface.
33+
With this backend it is possible to use picopickle for serialization using the official Mongo drivers.
34+
35+
It also serves as an example extended backend implementation with more types than the basic backend
36+
supports.
37+
38+
### Added support for changing STH discriminator key on per-STH basis.
39+
40+
It is now possible to change sealed trait hierarchy discriminator key for each sealed trait separately:
41+
42+
@discriminator("status") sealed trait Root
43+
case object Stopped extends Root
44+
case class Running(name: String) extends Root
45+
46+
writeString[Root](Stopped) shouldEqual """{"status":"Stopped"}"""
47+
writeString[Root](Running("me")) shouldEqual """{"status":"Running","name":"me"}"""
48+
49+
This allows even more flexibility in defining serialization formats, especially when matching some
50+
existing interface.
5351

5452
More information can be found in the [readme](https://github.com/netvl/picopickle#readme).
5553

0 commit comments

Comments
 (0)