mirror of
https://github.com/derfenix/webarchive.git
synced 2026-03-11 22:40:58 +03:00
Initial commit
This commit is contained in:
39
entity/result.go
Normal file
39
entity/result.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
)
|
||||
|
||||
type Result struct {
|
||||
Format Format
|
||||
Err error
|
||||
Files []File
|
||||
}
|
||||
|
||||
type Results struct {
|
||||
mu sync.RWMutex
|
||||
results []Result
|
||||
}
|
||||
|
||||
func (r *Results) MarshalMsgpack() ([]byte, error) {
|
||||
return msgpack.Marshal(r.results)
|
||||
}
|
||||
|
||||
func (r *Results) UnmarshalMsgpack(b []byte) error {
|
||||
return msgpack.Unmarshal(b, r.results)
|
||||
}
|
||||
|
||||
func (r *Results) Add(result Result) {
|
||||
r.mu.Lock()
|
||||
r.results = append(r.results, result)
|
||||
r.mu.Unlock()
|
||||
}
|
||||
|
||||
func (r *Results) Results() []Result {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
return r.results
|
||||
}
|
||||
Reference in New Issue
Block a user