pathmod_core

Crates.iopathmod_core
lib.rspathmod_core
version0.1.3
created_at2025-09-02 12:15:06.636554+00
updated_at2025-09-02 13:31:31.735493+00
descriptionCore runtime for pathmod accessors
homepagehttps://github.com/dahankzter/pathmod-rs
repositoryhttps://github.com/dahankzter/pathmod-rs
max_upload_size
id1821051
size14,848
Henrik Johansson (dahankzter)

documentation

https://docs.rs/pathmod_core

README

pathmod_core crate

Crates.io docs.rs

Purpose

  • Core runtime for Pathmod. Provides the Accessor<T, F> type and its safe methods for reading/mutating focused fields.
  • Used indirectly by most users via the re-export crate pathmod, but library authors may depend directly if they need only the runtime.

What is Accessor?

  • A tiny, Copy value that stores the byte offset from &T to &F.
  • Operations:
    • get(&T) -> &F
    • get_mut(&mut T) -> &mut F
    • set(&mut T, F)
    • set_mut(&mut T, impl FnOnce(&mut F))
    • set_clone(&mut T, &F) where F: Clone (MVP semantics: only the leaf value is cloned)
    • compose(self, Accessor<F, V>) -> Accessor<T, V>
  • Representation: offset-based; composition is O(1) addition of offsets. Public API is safe; unsafe is encapsulated inside.

Construction

  • Usually constructed by the derive macro from pathmod_derive (via #[derive(Accessor)]).
  • Also provides:
    • const unsafe fn from_offset(isize) for macro/const construction.
    • fn from_fns(get_ref, get_mut) for runtime construction (computes offset safely without dereferencing).

When should I depend on this crate directly?

  • If you are building your own derive/projection utilities or want to avoid a proc-macro dependency and construct accessors at runtime.
  • Otherwise, prefer pathmod which re-exports everything.

MSRV

  • Intended MSRV 1.89+ (matches usage of core::mem::offset_of! in the derive crate).

License Dual-licensed under MIT or Apache-2.0.

Commit count: 29

cargo fmt