Skip to content

Instantly share code, notes, and snippets.

@cablehead
Last active January 9, 2017 21:58
Show Gist options
  • Save cablehead/daa1bc1e08625434347e0cc66012a469 to your computer and use it in GitHub Desktop.
Save cablehead/daa1bc1e08625434347e0cc66012a469 to your computer and use it in GitHub Desktop.
r:stream():line() --> `err`, `Slice`
-- a slice is a restricted `off`, `len` window into a buffer. offers all methods buffer does.
-- is bump / growable, if `len` extends to the end of the buffer's current contents.
-- this allows you to make use of the line without incurring and additional copy
-- you call `:trim` when done with the line.
-- buffer (and so slice) will get two new methods
slice:string() -- just a rename of take, effectively ffi.string(slice:value()) and :trims
slice:data() -- returns copy as LeveeData, and :trims
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment