lisette-stdlib 0.1.13

Little language inspired by Rust that compiles to Go
Documentation
// Generated by Lisette bindgen
// Source: encoding/gob (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12

import "go:io"
import "go:reflect"

pub fn NewDecoder(r: io.Reader) -> Ref<Decoder>

pub fn NewEncoder(w: io.Writer) -> Ref<Encoder>

/// Register records a type, identified by a value for that type, under its
/// internal type name. That name will identify the concrete type of a value
/// sent or received as an interface variable. Only types that will be
/// transferred as implementations of interface values need to be registered.
/// Expecting to be used only during initialization, it panics if the mapping
/// between types and names is not a bijection.
pub fn Register(value: Unknown)

/// RegisterName is like [Register] but uses the provided name rather than the
/// type's default.
pub fn RegisterName(name: string, value: Unknown)

/// CommonType holds elements of all types.
/// It is a historical artifact, kept for binary compatibility and exported
/// only for the benefit of the package's encoding of type descriptors. It is
/// not intended for direct use by clients.
pub struct CommonType {
  pub Name: string,
  pub Id: int32,
}

/// A Decoder manages the receipt of type and data information read from the
/// remote side of a connection.  It is safe for concurrent use by multiple
/// goroutines.
/// 
/// The Decoder does only basic sanity checking on decoded input sizes,
/// and its limits are not configurable. Take caution when decoding gob data
/// from untrusted sources.
pub type Decoder

/// An Encoder manages the transmission of type and data information to the
/// other side of a connection.  It is safe for concurrent use by multiple
/// goroutines.
pub type Encoder

/// GobDecoder is the interface describing data that provides its own
/// routine for decoding transmitted values sent by a GobEncoder.
pub interface GobDecoder {
  fn GobDecode(arg0: Slice<uint8>) -> Result<(), error>
}

/// GobEncoder is the interface describing data that provides its own
/// representation for encoding values for transmission to a GobDecoder.
/// A type that implements GobEncoder and GobDecoder has complete
/// control over the representation of its data and may therefore
/// contain things such as private fields, channels, and functions,
/// which are not usually transmissible in gob streams.
/// 
/// Note: Since gobs can be stored permanently, it is good design
/// to guarantee the encoding used by a GobEncoder is stable as the
/// software evolves. For instance, it might make sense for GobEncode
/// to include a version number in the encoding.
pub interface GobEncoder {
  fn GobEncode() -> Result<Slice<uint8>, error>
}

impl Decoder {
  /// Decode reads the next value from the input stream and stores
  /// it in the data represented by the empty interface value.
  /// If e is nil, the value will be discarded. Otherwise,
  /// the value underlying e must be a pointer to the
  /// correct type for the next data item received.
  /// If the input is at EOF, Decode returns [io.EOF] and
  /// does not modify e.
  fn Decode(self: Ref<Decoder>, e: Unknown) -> Result<(), error>

  /// DecodeValue reads the next value from the input stream.
  /// If v is the zero reflect.Value (v.Kind() == Invalid), DecodeValue discards the value.
  /// Otherwise, it stores the value into v. In that case, v must represent
  /// a non-nil pointer to data or be an assignable reflect.Value (v.CanSet())
  /// If the input is at EOF, DecodeValue returns [io.EOF] and
  /// does not modify v.
  fn DecodeValue(self: Ref<Decoder>, v: reflect.Value) -> Result<(), error>
}

impl Encoder {
  /// Encode transmits the data item represented by the empty interface value,
  /// guaranteeing that all necessary type information has been transmitted first.
  /// Passing a nil pointer to Encoder will panic, as they cannot be transmitted by gob.
  fn Encode(self: Ref<Encoder>, e: Unknown) -> Result<(), error>

  /// EncodeValue transmits the data item represented by the reflection value,
  /// guaranteeing that all necessary type information has been transmitted first.
  /// Passing a nil pointer to EncodeValue will panic, as they cannot be transmitted by gob.
  fn EncodeValue(self: Ref<Encoder>, value: reflect.Value) -> Result<(), error>
}