nbdkit_parse_size(3)

πŸ’– nbdkit_parse_size β€” the manual page, bestie edition πŸ’–

okay so welcome to nbdkit_parse_size(3), a page from the NBDKIT manual, section 3. sit down, grab a boba, we're parsing sizes and we're gonna eat πŸ“


✨ NAME ✨

nbdkit_parse_size β€” parse human-readable size strings for nbdkit

like, you say 100M and it's like "oh word, that's a number of bytes" πŸ’… no cap.


🌸 SYNOPSIS 🌸

#include <nbdkit-plugin.h>

int64_t nbdkit_parse_size (const char *str);

there it is. one function. one job. iconic behaviour honestly πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so you're gonna use the nbdkit_parse_size utility function to parse human-readable size strings like "100M" and turn them into the size in bytes. that's the whole vibe. that's the assignment. and it ate. πŸ”₯

the str parameter is a string, and it can be in a number of common formats. yes bestie, formats, plural β€” that's not me being vague, that's just what the page says, so we keep it πŸ’œ


πŸ’– RETURN VALUE πŸ’–

  • the function returns the size in bytes πŸŽ€
  • but if there's an error? plot twist 😭 it calls nbdkit_error(3) and returns -1.
lowkey important: -1 means something went wrong, not "negative one bytes of storage". check your error handling fr fr πŸ™ˆ

🌈 LANGUAGE BINDINGS 🌈

bestie it's polyglot, it speaks everyone's language πŸ’…

πŸ’œ In nbdkit-ocaml-plugin(3):

NBDKit.parse_size : string -> int64

πŸ’œ In nbdkit-python-plugin(3):

import nbdkit
size = nbdkit.parse_size(str)

πŸ’œ In nbdkit-rust-plugin(3):

use nbdkit::*;
pub fn parse_size(s: &str) -> Result<i64>

πŸ’œ In nbdkit-sh-plugin(3):

okay so here's the cute part β€” nbdkit_parse_size gets called implicitly to parse the output of get_size and other methods. you don't even have to ask. it just shows up. main character energy ✨


πŸŽ€ HISTORY πŸŽ€

nbdkit_parse_size was present in nbdkit 0.1.0. so like, day one. OG status. it's been here since the beginning and we respect it 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, they're all part of the friend group:


πŸ’€ AUTHORS πŸ’€

Richard W.M. Jones

(the legend themselves, we stan 🌟)


Copyright Red Hat


πŸ“œ LICENSE πŸ“œ

okay bestie, legal time, but make it cute. redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
fr fr read that one, it's the "no promises, don't sue us" clause and it means exactly what it says πŸ’€

and that's the page!! this was nbdkit-1.48.1, dated 2026-08-29, and it lives in the nbdkit family forever. mwah πŸ’‹ go parse some sizes, bestie, you're gonna slay πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from