Skip to content

Commit

Permalink
Update README.md for packet.shiftleft et al
Browse files Browse the repository at this point in the history
Probably we should document something about packet.prepend mostly being
O(1) and the sliding "struct packet" mechanism also.
  • Loading branch information
wingo committed Oct 20, 2016
1 parent 21759e2 commit e115542
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/README.md
Expand Up @@ -355,8 +355,8 @@ packets are allocated and freed.

```
struct packet {
uint8_t data[packet.max_payload];
uint16_t length;
uint8_t data[packet.max_payload];
};
```

Expand Down Expand Up @@ -393,18 +393,21 @@ error is raised if there is not enough space in *packet* to accomodate
— Function **packet.prepend** *packet*, *pointer*, *length*

Prepends *length* bytes starting at *pointer* to the front of
*packet*. An error is raised if there is not enough space in *packet* to
*packet*, taking ownership of the packet and returning a new packet.
An error is raised if there is not enough space in *packet* to
accomodate *length* additional bytes.

— Function **packet.shiftleft** *packet*, *length*

Truncates *packet* by *length* bytes from the front. *Length* must be less than
or equal to `length` of *packet*.
Take ownership of *packet*, truncate it by *length* bytes from the
front, and return a new packet. *Length* must be less than or equal to
`length` of *packet*.

— Function **packet.shiftright** *packet*, *length*

Moves *packet* payload to the right by *length* bytes, growing *packet* by
*length*. The sum of *length* and `length` of *packet* must be less than or
Take ownership of *packet*, moves *packet* payload to the right by
*length* bytes, growing *packet* by *length*. Returns a new packet.
The sum of *length* and `length` of *packet* must be less than or
equal to `packet.max_payload`.

— Function **packet.from_pointer** *pointer*, *length*
Expand Down

0 comments on commit e115542

Please sign in to comment.