github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/marshal/marshal_impl_util.go (about)

     1  // Copyright 2020 The gVisor 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  //     http://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  package marshal
    16  
    17  import (
    18  	"io"
    19  
    20  	"github.com/SagerNet/gvisor/pkg/hostarch"
    21  )
    22  
    23  // StubMarshallable implements the Marshallable interface.
    24  // StubMarshallable is a convenient embeddable type for satisfying the
    25  // marshallable interface, but provides no actual implementation. It is
    26  // useful when the marshallable interface needs to be implemented manually,
    27  // but the caller doesn't require the full marshallable interface.
    28  type StubMarshallable struct{}
    29  
    30  // WriteTo implements Marshallable.WriteTo.
    31  func (StubMarshallable) WriteTo(w io.Writer) (n int64, err error) {
    32  	panic("Please implement your own WriteTo function")
    33  }
    34  
    35  // SizeBytes implements Marshallable.SizeBytes.
    36  func (StubMarshallable) SizeBytes() int {
    37  	panic("Please implement your own SizeBytes function")
    38  }
    39  
    40  // MarshalBytes implements Marshallable.MarshalBytes.
    41  func (StubMarshallable) MarshalBytes(dst []byte) {
    42  	panic("Please implement your own MarshalBytes function")
    43  }
    44  
    45  // UnmarshalBytes implements Marshallable.UnmarshalBytes.
    46  func (StubMarshallable) UnmarshalBytes(src []byte) {
    47  	panic("Please implement your own UnmarshalBytes function")
    48  }
    49  
    50  // Packed implements Marshallable.Packed.
    51  func (StubMarshallable) Packed() bool {
    52  	panic("Please implement your own Packed function")
    53  }
    54  
    55  // MarshalUnsafe implements Marshallable.MarshalUnsafe.
    56  func (StubMarshallable) MarshalUnsafe(dst []byte) {
    57  	panic("Please implement your own MarshalUnsafe function")
    58  }
    59  
    60  // UnmarshalUnsafe implements Marshallable.UnmarshalUnsafe.
    61  func (StubMarshallable) UnmarshalUnsafe(src []byte) {
    62  	panic("Please implement your own UnmarshalUnsafe function")
    63  }
    64  
    65  // CopyIn implements Marshallable.CopyIn.
    66  func (StubMarshallable) CopyIn(cc CopyContext, addr hostarch.Addr) (int, error) {
    67  	panic("Please implement your own CopyIn function")
    68  }
    69  
    70  // CopyOut implements Marshallable.CopyOut.
    71  func (StubMarshallable) CopyOut(cc CopyContext, addr hostarch.Addr) (int, error) {
    72  	panic("Please implement your own CopyOut function")
    73  }
    74  
    75  // CopyOutN implements Marshallable.CopyOutN.
    76  func (StubMarshallable) CopyOutN(cc CopyContext, addr hostarch.Addr, limit int) (int, error) {
    77  	panic("Please implement your own CopyOutN function")
    78  }