Skip to content

Commit

Permalink
remove Cstruct.t
Browse files Browse the repository at this point in the history
  • Loading branch information
palainp committed Sep 29, 2024
1 parent 3f75f8a commit 97b8306
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion mirage-net.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ depends: [
"dune" {>= "1.0"}
"fmt"
"macaddr" {>= "4.0.0"}
"cstruct" {>= "4.0.0"}
"lwt" {>= "4.0.0"}
]
synopsis: "Network signatures for MirageOS"
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(library
(name mirage_net)
(public_name mirage-net)
(libraries fmt cstruct macaddr lwt))
(libraries fmt macaddr lwt))
4 changes: 2 additions & 2 deletions src/mirage_net.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ module type S = sig
val pp_error: error Fmt.t
type t
val disconnect : t -> unit Lwt.t
val write: t -> size:int -> (Cstruct.t -> int) -> (unit, error) result Lwt.t
val listen: t -> header_size:int -> (Cstruct.t -> unit Lwt.t) -> (unit, error) result Lwt.t
val write: t -> size:int -> (Bytes.t -> int) -> (unit, error) result Lwt.t
val listen: t -> header_size:int -> (Bytes.t -> unit Lwt.t) -> (unit, error) result Lwt.t
val mac: t -> Macaddr.t
val mtu: t -> int
val get_stats_counters: t -> stats
Expand Down
4 changes: 2 additions & 2 deletions src/mirage_net.mli
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ module type S = sig
(** Disconnect from the network device. While this might take some time to
complete, it can never result in an error. *)

val write: t -> size:int -> (Cstruct.t -> int) -> (unit, error) result Lwt.t
val write: t -> size:int -> (Bytes.t -> int) -> (unit, error) result Lwt.t
(** [write net ~size fill] allocates a buffer of length [size], where [size]
must not exceed the interface maximum packet size ({!mtu} plus Ethernet
header). The allocated buffer is zeroed and passed to the [fill] function
which returns the payload length, which may not exceed the length of the
buffer. When [fill] returns, a sub buffer is put on the wire: the allocated
buffer from index 0 to the returned length. *)

val listen: t -> header_size:int -> (Cstruct.t -> unit Lwt.t) -> (unit, error) result Lwt.t
val listen: t -> header_size:int -> (Bytes.t -> unit Lwt.t) -> (unit, error) result Lwt.t
(** [listen ~header_size net fn] waits for a [packet] with size at most
[header_size + mtu] on the network device. When a [packet] is received, an
asynchronous task is created in which [fn packet] is called. The ownership
Expand Down

1 comment on commit 97b8306

@hannesm
Copy link
Member

@hannesm hannesm commented on 97b8306 Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to use bytes -> int in write, and string -> unit Lwt.t in listen -- to have it clear that for write the fill callback will mutate the buffer, and in listen the received data is read-only.

Please sign in to comment.