From a51ebbedb1147032f2f5e40b5f52019df5af0eb9 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 25 Nov 2025 08:00:00 +0800 Subject: zlibx: reader -> constants --- internal/zlibx/constants.go | 52 +++++++++++++++++++++++++++++++++++++++++++++ internal/zlibx/reader.go | 52 --------------------------------------------- 2 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 internal/zlibx/constants.go delete mode 100644 internal/zlibx/reader.go diff --git a/internal/zlibx/constants.go b/internal/zlibx/constants.go new file mode 100644 index 00000000..161e3458 --- /dev/null +++ b/internal/zlibx/constants.go @@ -0,0 +1,52 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* +Package zlibx implements reading of zlib format compressed data, +as specified in RFC 1950. + +This package differs from the standard library's compress/zlib package +in that it pools readers to reduce allocations. Writing is unsupported. + +THis package will likely be refactorered much more for our specific +use case of only doing full decompressions to byte slices. + +Note that closing the reader causes it to be returned to a pool for +reuse. Therefore, the caller must not retain references to the +reader after closing it; in the standard library's compress/zlib package, +it is legal to Reset a closed reader and continue using it; that is +not allowed here, so there is simply no Resetter interface. + +The implementation provides filters that uncompress during reading +and compress during writing. For example, to write compressed data +to a buffer: + + var b bytes.Buffer + w := zlib.NewWriter(&b) + w.Write([]byte("hello, world\n")) + w.Close() + +and to read that data back: + + r, err := zlib.NewReader(&b) + io.Copy(os.Stdout, r) + r.Close() +*/ +package zlibx + +import ( + "errors" +) + +const ( + zlibDeflate = 8 + zlibMaxWindow = 7 +) + +var ( + // ErrChecksum is returned when reading ZLIB data that has an invalid checksum. + ErrChecksum = errors.New("zlib: invalid checksum") + // ErrHeader is returned when reading ZLIB data that has an invalid header. + ErrHeader = errors.New("zlib: invalid header") +) diff --git a/internal/zlibx/reader.go b/internal/zlibx/reader.go deleted file mode 100644 index 161e3458..00000000 --- a/internal/zlibx/reader.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package zlibx implements reading of zlib format compressed data, -as specified in RFC 1950. - -This package differs from the standard library's compress/zlib package -in that it pools readers to reduce allocations. Writing is unsupported. - -THis package will likely be refactorered much more for our specific -use case of only doing full decompressions to byte slices. - -Note that closing the reader causes it to be returned to a pool for -reuse. Therefore, the caller must not retain references to the -reader after closing it; in the standard library's compress/zlib package, -it is legal to Reset a closed reader and continue using it; that is -not allowed here, so there is simply no Resetter interface. - -The implementation provides filters that uncompress during reading -and compress during writing. For example, to write compressed data -to a buffer: - - var b bytes.Buffer - w := zlib.NewWriter(&b) - w.Write([]byte("hello, world\n")) - w.Close() - -and to read that data back: - - r, err := zlib.NewReader(&b) - io.Copy(os.Stdout, r) - r.Close() -*/ -package zlibx - -import ( - "errors" -) - -const ( - zlibDeflate = 8 - zlibMaxWindow = 7 -) - -var ( - // ErrChecksum is returned when reading ZLIB data that has an invalid checksum. - ErrChecksum = errors.New("zlib: invalid checksum") - // ErrHeader is returned when reading ZLIB data that has an invalid header. - ErrHeader = errors.New("zlib: invalid header") -) -- cgit v1.3.1-10-gc9f91