Articles tagged #api-design

Page 1
The thumbnail for this page

A simple ping library, parsing strings into IPv4 address

Oct 12, 2019
13 min #networking · #icmp · #rust · #ffi · #win32 · #api-design

We’ve just spent a lot of time abstracting over LoadLibrary, but we still have all the gory details of the Win32 ICMP API straight in our main.rs file! That won’t do.

This time will be much quicker, since we already learned about carefully designing an API, hiding the low-level bits and so on.

Let’s add an icmp module to our program. Actually, we’ve been dealing with an IPAddr all this time, it also sounds like it could use its own package:

Read more
The thumbnail for this page

Designing and implementing a safer API on top of LoadLibrary

Oct 04, 2019
18 min #rust · #win32 · #ffi · #api-design

It’s refactor time!

Our complete program is now about a hundred lines, counting blank lines (see the end of part 3 for a complete listing).

While this is pretty good for a zero-dependency project (save for pretty-hex), we can do better.

First off, concerns are mixed up. In the same file, we:

  • Expose LoadLibraryA / GetProcAddress
  • Expose the Win32 ICMP API
Read more
Page 1

Go back to the homepage.

Ko-fi GitHub Sponsors Patreon
Bluesky Mastodon YouTube
TikTok Instagram RSS
About Legal Notice Privacy Policy Terms and Conditions