Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Source Struct Referenceabstract

#include <serialise.hh>

Inheritance diagram for nix::Source:
nix::BufferedSource nix::ChainSource nix::EnsureRead nix::FramedSource nix::LambdaSource nix::LengthSource nix::RestartableSource nix::SizedSource nix::TeeSource

Public Member Functions

void operator() (char *data, size_t len)
void operator() (std::string_view data)
virtual size_t read (char *data, size_t len)=0
virtual bool good ()
void drainInto (Sink &sink)
virtual void drainInto (Sink &sink, uint64_t len)
std::string drain ()
virtual void skip (size_t len)

Detailed Description

Abstract source of binary data.

Member Function Documentation

◆ drainInto() [1/2]

void nix::Source::drainInto ( Sink & sink)

Read the rest of this Source into sink.

◆ drainInto() [2/2]

void nix::Source::drainInto ( Sink & sink,
uint64_t len )
virtual

Read exactly 'len' bytes and write them to 'sink'.

Virtual in anticipation that some Source implementations, like FdSource may eventually be able to provide more performant implementations of this function.

◆ operator()()

void nix::Source::operator() ( char * data,
size_t len )

Store exactly ‘len’ bytes in the buffer pointed to by ‘data’. It blocks until all the requested data is available, or throws an error if it is not going to be available.

◆ read()

virtual size_t nix::Source::read ( char * data,
size_t len )
pure virtual

Store up to ‘len’ in the buffer pointed to by ‘data’, and return the number of bytes stored. It blocks until at least one byte is available.

Implemented in nix::BufferedSource, nix::ChainSource, nix::EnsureRead, nix::FramedSource, nix::LambdaSource, nix::LengthSource, nix::SizedSource, nix::StringSource, and nix::TeeSource.


The documentation for this struct was generated from the following files:
  • libutil/include/nix/util/serialise.hh
  • libutil/serialise.cc