1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

use io.WriterTo instead of custom save interface ti serialize metadata and rolie.

This commit is contained in:
Sascha L. Teichmann 2021-12-02 00:24:27 +01:00
parent 5276cea0a0
commit 22c7da1ed1
4 changed files with 24 additions and 13 deletions

View file

@ -68,11 +68,13 @@ func LoadROLIEFeed(r io.Reader) (*ROLIEFeed, error) {
return &rf, nil
}
// Save saves a ROLIE feed to a writer.
func (rf *ROLIEFeed) Save(w io.Writer) error {
// WriteTo saves a ROLIE feed to a writer.
func (rf *ROLIEFeed) WriteTo(w io.Writer) (int64, error) {
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
return enc.Encode(rf)
nw := nWriter{w, 0}
err := enc.Encode(&nw)
return nw.n, err
}
// EntryByID looks up an entry by its ID.