Skip to main content

extract_bytes

Function extract_bytes 

Source
pub fn extract_bytes(
    path: &Path,
    language: Language,
    content: &[u8],
    config: &Config,
) -> Result<FileFeatures, Error>
Expand description

Extracts a file whose content is already in memory (e.g. read from a git revision).

§Errors

The errors of extract_source.

§Examples

use std::path::Path;
use pelicode_core::{Config, Language, extract_bytes};

let source = b"package main\nfunc Add(a, b int) int { return a + b }\n";
let file = extract_bytes(Path::new("add.go"), Language::Go, source, &Config::default()).unwrap();
assert_eq!(file.functions[0].name, "Add");
assert_eq!(file.content_sha256.len(), 64);