From 04a706dad9133187734827e91d569b893005591c Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Mon, 17 Nov 2025 12:57:46 +0100 Subject: [PATCH] Add code snippet to README.md --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 0819694..138eeba 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,34 @@ You can use ToastyFS to store your files reliably over multiple machines knowing 🎵 Now let's get toasty 🎵 +ToastyFS works by running nodes on multiple machines. Clients using the ToastyFS C library can then send file operations to the cluster. Here's a quick example: + +```c +#include + +int main(void) +{ + ToastyString addr = TOASTY_STR("127.0.0.1"); + int port = 8080; + ToastyString file = TOASTY_STR("/my_file.txt"); + + // Connect to cluster + ToastyFS *toasty = toasty_connect(addr, port); + + // Create and write to a file + toasty_create_file(toasty, file, 4096); + toasty_write(toasty, file, 0, "Hello!", 6); + + // Read it back + char buf[6]; + toasty_read(toasty, file, 0, buf, 6); + + // Done! + toasty_disconnect(toasty); + return 0; +} +``` + ## Features - Cross-platform (runs on Windows and Linux)