MCPcopy Create free account
hub / github.com/klauspost/compress / ResetWithOptions

Method ResetWithOptions

zstd/encoder.go:164–184  ·  view source on GitHub ↗

ResetWithOptions will re-initialize the writer and apply the given options as a new, independent stream. Options are applied on top of the existing options. Some options cannot be changed on reset and will return an error.

(w io.Writer, opts ...EOption)

Source from the content-addressed store, hash-verified

162// Options are applied on top of the existing options.
163// Some options cannot be changed on reset and will return an error.
164func (e *Encoder) ResetWithOptions(w io.Writer, opts ...EOption) error {
165 e.o.resetOpt = true
166 defer func() { e.o.resetOpt = false }()
167 hadDict := e.o.dict != nil
168 for _, o := range opts {
169 if err := o(&e.o); err != nil {
170 return err
171 }
172 }
173 hasDict := e.o.dict != nil
174 if e.o.concurrentBlocks && hasDict {
175 e.o.concurrentBlocks = false
176 }
177 if hadDict != hasDict {
178 // Dict presence changed — encoder type must be recreated.
179 e.state.encoder = nil
180 e.init = sync.Once{}
181 }
182 e.Reset(w)
183 return nil
184}
185
186// ResetContentSize will reset and set a content size for the next stream.
187// If the bytes written does not match the size given an error will be returned

Callers

nothing calls this directly

Calls 1

ResetMethod · 0.95

Tested by

no test coverage detected