Skip to content

v.embed_file #

fn find_index_entry_by_path #

fn find_index_entry_by_path(start voidptr, path string, algo string) &EmbedFileIndexEntry

find_index_entry_by_path is used internally by the V compiler:

fn register_decoder #

fn register_decoder(compression_type string, decoder Decoder)

interface Decoder #

interface Decoder {
	decompress([]u8) ![]u8
}

struct EmbedFileData #

struct EmbedFileData {
	apath            string
	compression_type string
mut:
	compressed        &u8 = unsafe { nil }
	uncompressed      &u8 = unsafe { nil }
	free_compressed   bool
	free_uncompressed bool
pub:
	len  int
	path string
}

EmbedFileData encapsulates functionality for the $embed_file() compile time call.

fn (EmbedFileData) str #

fn (ed EmbedFileData) str() string

fn (EmbedFileData) free #

unsafe
fn (mut ed EmbedFileData) free()

fn (EmbedFileData) to_string #

fn (original &EmbedFileData) to_string() string

fn (EmbedFileData) to_bytes #

fn (original &EmbedFileData) to_bytes() []u8

fn (EmbedFileData) data #

fn (mut ed EmbedFileData) data() &u8

struct EmbedFileIndexEntry #

struct EmbedFileIndexEntry {
	id   int
	path string
	algo string
	data &u8 = unsafe { nil }
}

//////////////////////////////////////////////////////////////////////////// EmbedFileIndexEntry is used internally by the V compiler when you compile a program that uses $embed_file('file.bin') in -prod mode. V will generate a static index of all embedded files, and will call the find_index_entry_by_path over the index and the relative paths of the embeds.

Note: these are public on purpose, to help -usecache.