1// Copyright 2019 The Wuffs Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//    https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// ----------------
16
17// +build !cgo
18
19package cgozstd
20
21// This file contains placeholder types and funcs so that the package still
22// builds (with the same API) when CGO_ENABLED=0. The package doesn't work
23// without cgo, but it will fail at run time, not compile time.
24//
25// In particular, the build stays green regardless of whether CGO_ENABLED is on
26// or off. Installing and testing every package in the whole repository will
27// not fail. The tests in this package don't pass, but they are skipped.
28
29import (
30	"errors"
31	"io"
32
33	"github.com/google/wuffs/lib/compression"
34)
35
36const cgoEnabled = false
37
38var (
39	errCgoIsNotEnabled = errors.New("cgozstd: cgo is not enabled")
40)
41
42type ReaderRecycler struct{}
43
44func (c *ReaderRecycler) Bind(*Reader) {}
45func (c *ReaderRecycler) Close() error { return errCgoIsNotEnabled }
46
47type Reader struct{}
48
49func (r *Reader) Close() error                  { return errCgoIsNotEnabled }
50func (r *Reader) Read([]byte) (int, error)      { return 0, errCgoIsNotEnabled }
51func (r *Reader) Reset(io.Reader, []byte) error { return errCgoIsNotEnabled }
52
53type WriterRecycler struct{}
54
55func (c *WriterRecycler) Bind(*Writer) {}
56func (c *WriterRecycler) Close() error { return errCgoIsNotEnabled }
57
58type Writer struct{}
59
60func (w *Writer) Close() error                                     { return errCgoIsNotEnabled }
61func (w *Writer) Reset(io.Writer, []byte, compression.Level) error { return errCgoIsNotEnabled }
62func (w *Writer) Write([]byte) (int, error)                        { return 0, errCgoIsNotEnabled }
63