Skip to content

Commit

Permalink
Delete impl. of Cstruct_cap.to_{bytes,string} and use default impl. p…
Browse files Browse the repository at this point in the history
…rovided by Cstruct module
  • Loading branch information
dinosaure committed Sep 15, 2020
1 parent be3efd0 commit 7fd10ac
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions lib/cstruct_cap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ external wo : 'a wr t -> wo t = "%identity"
let of_string = Cstruct.of_string ?allocator:None
let of_bytes = Cstruct.of_bytes ?allocator:None

let to_string ?(off= 0) ?len t =
let len = match len with
| Some len -> len
| None -> Cstruct.length t - off in
Cstruct.copy t off len

let to_bytes ?(off= 0) ?len t =
let len = match len with
| Some len -> len
| None -> Cstruct.length t - off in
(* XXX(dinosaure): this is safe when [copy] allocates itself [bytes]
and uses [Bytes.unsafe_to_string]. *)
Bytes.unsafe_of_string (Cstruct.copy t off len)

let pp ppf t = Cstruct.hexdump_pp ppf t

let length = Cstruct.length
Expand Down

0 comments on commit 7fd10ac

Please sign in to comment.