Module Fragments.Make

Parameters

Signature

type t

The type of a mutable cache.

val create : ?to_expire:int -> unit -> t

create ?to_expire () creates a new cache where fragments are kept until to_expire nanoseconds (defaults to 10s).

val insert : now:int -> t -> Key.t -> ?last:bool -> off:int -> len:int -> SBstr.t -> (Key.t * payload) option

insert ~now cache key ?last ~off ~len slice inserts a new slice into the given cache identified by the given key. The user can specify a sub-view of the given slice and must informs if the payload is the last one or not with the last value (defaults to false).

If the cache is able to reassemble packets identified by key or if the given slice is not fragmented, it returns the key and the data. Otherwise, it returns None.