Pudu programming language
Menu
API reference

Std.Net.receiveUntil

1 declaration

fn

receiveUntil: &Std.Net.Connection -> &Bytes -> Int -> Result[(Bytes, Bytes), Std.Net.NetError]

This is a callable function.

What it does

Read until a marker has arrived, answering what came before it and what

came after.

This is what a protocol whose messages end with a marker needs, and it is

the operation such a reader most often gets wrong: the marker can arrive

split across two reads, so a reader that looked only at the newest chunk

would miss it. The buffer is searched whole each time.

The remainder is answered rather than dropped because it is the start of

the next message: a reader that discarded it would lose the beginning of

everything that followed.

Read the signature

  • The text after the name is the type checked by Pudu.
  • Read arrows from left to right: inputs come first, and the final type is returned.
  • & borrows a value for this call instead of moving or copying it.
  • Names inside [ ] are type arguments, such as the item type held by a collection.
  • Result makes success and recoverable failure part of the function's type.

Back to Std.NetSearch related declarations