Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.02 KB

File metadata and controls

42 lines (30 loc) · 1.02 KB

zswap

Async Rust library for querying Zswap information on Linux.

crates.io

Installation

To install the latest version of the crate from crates.io, run:

$ cargo add zswap

Getting started

To get started, create a new program that prints Zswap usage information:

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
	let enabled = zswap::param::enabled().await?;
	if !enabled {
		eprintln!("Zswap is not enabled");
		return Ok(());
	}

	let compressed = zswap::compressed().await?;
	let uncompressed = zswap::uncompressed().await?;
	let ratio = zswap::ratio().await?;
	println!("Compressed size: {compressed} B");
	println!("Uncompressed size: {uncompressed} B");
	println!("Compression ratio: {ratio}");
	Ok(())
}

License

This crate is distributed under the terms of MIT License.

See LICENSE for details.