Module source

Data sources that may be used with buffers instead of directly filling or using lambdas

<

Example

Extension Interface

It is possible to have objects act as sources by inserting a lamda returning function in a struct or class.

 
struct mystruct(T)
{
 auto src()
 {
  return (T[] x) 
  {
   // Write to x
   x[] = x.init;
		
   // Return written count
   return x.length;
  };
 }	
}

Example

Built-in Sources

There are built-in example sources, which you may use instead of directly filling using concat or lambdas.

import source;
import elembuf;

auto buf = buffer("");
auto src = "www.bing.com".NetSource;

while(buf.length == 0)
	buf ~= src;

 auto srcarr = "World".ArraySource!char;

 buf.length = 0;
 buf ~= srcarr;
 assert(buf == "World");

Structs

NameDescription
ArraySource Source that reads from an array as if it were a true source.
NetSource Source which takes data from a website.