chenzehaoo/moon_guard/lib/manifest does not have a README file

    FileEntry

    pub(all) struct FileEntry {
    path : String
    content : String
    }

    FileHash

    pub struct FileHash {
    path : String
    hash : String
    size : Int
    } derive(Eq)

    MoonGuard Manifest Module Package manifest generation and hash calculation

    Manifest

    pub struct Manifest {
    version : String
    package_name : String
    package_version : String
    total_files : Int
    total_size : Int
    created_at : String
    files : Array[FileHash]
    }

    Manifest::new

    fn Manifest::new(package_name : String, package_version : String) -> Manifest

    Create a new manifest

    compute_file_hash

    fn compute_file_hash(entry : FileEntry) -> FileHash

    Compute hash for a single file entry

    generate_manifest

    fn generate_manifest(package_name : String, package_version : String, entries : Array[FileEntry]) -> Manifest

    Generate manifest from a list of file entries

    hash_string

    fn hash_string(content : String) -> String

    Hash string content

    manifest_from_json

    fn manifest_from_json(json : String) -> Manifest?

    Parse a manifest_to_json document back into a Manifest. Returns None when the document is malformed so the caller can fall back to a freshly generated manifest. This is what lets the CLI audit an existing on-disk manifest.json instead of only freshly generated ones.

    manifest_summary

    fn manifest_summary(manifest : Manifest) -> String

    Get manifest summary

    manifest_to_json

    fn manifest_to_json(manifest : Manifest) -> String

    Serialize manifest to JSON string

    sha256

    fn sha256(data : String) -> String

    Calculate SHA-256 hash of a string

    slice_chars_

    fn slice_chars_(s : String, start : Int, end_ : Int) -> String

    Take the inclusive-exclusive [start, end) slice of s. Replaces the deprecated String::substring(start, end) call site used by the verify and CLI modules.

    take_chars_

    fn take_chars_(s : String, n : Int) -> String

    Take the first n characters of s. Replaces the deprecated String::substring(start=0, end=n) call site used by the verify and CLI modules.

    verify_manifest

    fn verify_manifest(manifest : Manifest, entries : Array[FileEntry]) -> Array[String]

    Verify file entries against an existing manifest, returns list of mismatched paths

    Source Files