runar_common

Crates.iorunar_common
lib.rsrunar_common
version0.1.0
created_at2025-08-14 10:42:07.690697+00
updated_at2025-08-14 10:42:07.690697+00
descriptionCommon traits and utilities for the Runar framework
homepagehttps://github.com/runar-labs/runar-rust
repositoryhttps://github.com/runar-labs/runar-rust
max_upload_size
id1794727
size47,512
Rafael Almeida (pentateu)

documentation

https://docs.rs/runar_common

README

Runar Common

Common traits and utilities shared across the Runar stack.

What’s inside

  • Structured logging with component and node-id context
  • Lightweight error utilities (re-exports of anyhow and thiserror)
  • DNS-safe compact ID generator

Install

Add to your Cargo.toml:

[dependencies]
runar_common = "0.1"

Logging

use runar_common::logging::{Component, Logger};

let root = Logger::new_root(Component::Node, "node-123");
let svc = root.with_component(Component::Service);
svc.info("service started");
svc.warn("doing work");
svc.error("something went wrong");

Compact IDs

use runar_common::compact_ids::compact_id;

let public_key_bytes: [u8; 65] = [0u8; 65];
let id = compact_id(&public_key_bytes);
assert_eq!(id.len(), 26);
assert!(id.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit()));

Errors

use runar_common::errors::{Result, anyhow};

fn do_work() -> Result<()> {
    // ...
    Err(anyhow!("failure"))
}

License

MIT. See LICENSE.

Commit count: 0

cargo fmt