open Core.Std
module Pair = struct
}
let key t = t.key
let value t = t.value
end
module Link = struct
end
module Content = struct
; content_type
: string option ; content_encoding
: string option ; last_mod
: Int32.t
option ; last_mod_usec
: Int32.t
option }
let of_content pb =
let module Robj = Pb_robj.Robj in
let module C = Pb_robj.Content in
let pair_of_pair { Pb_robj.Pair.key; value } =
{ Pair.key = key; value = value }
in
let usermeta =
~f:pair_of_pair
pb.C.usermeta
in
let indexes =
~f:pair_of_pair
pb.C.indexes
in
{ value = pb.C.value
; content_type = pb.C.content_type
; charset = pb.C.content_type
; content_encoding = pb.C.content_encoding
; vtag = pb.C.vtag
; links = [()]
; last_mod = pb.C.last_mod
; last_mod_usec = pb.C.last_mod_usec
; usermeta = usermeta
; indexes = indexes
; deleted = Option.value ~default:false pb.C.deleted
}
let to_content c =
let module Robj = Pb_robj.Robj in
let module C = Pb_robj.Content in
let pair_of_pair { Pair.key = key; value = value } =
{ Pb_robj.Pair.key; value }
in
let usermeta =
~f:pair_of_pair
c.usermeta
in
let indexes =
~f:pair_of_pair
c.indexes
in
{ C.value = c.value
; content_type = c.content_type
; charset = c.charset
; content_encoding = c.content_encoding
; vtag = c.vtag
; links = []
; last_mod = c.last_mod
; last_mod_usec = c.last_mod_usec
; usermeta = usermeta
; indexes = indexes
; deleted = Some c.deleted
}
let of_pb
= List.map
~f:(of_content
) let to_pb
= List.map
~f:(to_content
)
let value t = t.value
let content_type t = t.content_type
let charset t = t.charset
let content_encoding t = t.content_encoding
let vtag t = t.vtag
let last_mod t = t.last_mod
let last_mod_usec t = t.last_mod_usec
let usermeta t = t.usermeta
let indexes t = t.indexes
let deleted t = t.deleted
end
type 'a t
= { contents
: Content
.t
list }
let of_pb pb =
let module Robj = Pb_robj.Robj in
let contents = Content.of_pb pb.Robj.contents in
{ contents = contents
; vclock = pb.Robj.vclock
; unchanged = Option.value ~default:false pb.Robj.unchanged
}
let to_pb t =
let module Robj = Pb_robj.Robj in
let contents = Content.to_pb t.contents in
{ Robj.contents = contents
; vclock = t.vclock
; unchanged = Some t.unchanged
}
let no_siblings_of_t t =
match t.contents with
| [_] -> Ok t
| _ -> Error `Has_siblings
let contents t = t.contents
let content t
= List.hd_exn
(t
.contents
) let set_contents t cs = { t with contents = cs }
let set_content t c = { t with contents = [c] }
let vclock t = t.vclock
let unchanged t = t.unchanged