Struct fpm::Config[][src]

pub struct Config {
    pub package: Package,
    pub root: Utf8PathBuf,
    pub original_directory: Utf8PathBuf,
    pub fonts: Vec<Font>,
    pub dependencies: Vec<Dependency>,
    pub ignored: Override,
}
Expand description

Config struct keeps track of a few configuration parameters that is shared with the entire program. It is constructed from the content of FPM.ftd file for the package.

Config is created using Config::read() method, and should be constructed only once in the main() and passed everywhere.

Fields

package: Packageroot: Utf8PathBuf

root is the package root folder, this is the folder where FPM.ftd file is stored.

Technically the rest of the program can simply call std::env::current_dir() and that is guaranteed to be same as Config.root, but Config.root is camino path, instead of std::path::Path, so we can treat root as a handy helper.

A utility that returns camino version of current_dir() may be used in future.

original_directory: Utf8PathBuf

original_directory is the directory from which the fpm command was invoked

During the execution of fpm, we change the directory to the package root so the program can be written with the assumption that they are running from package root.

When printing filenames for users consumption we want to print the paths relative to the original_directory, so we keep track of the original directory.

fonts: Vec<Font>

fonts keeps track of the fonts used by the package.

Note that this too is kind of bad design, we will move fonts to fpm::Package struct soon.

dependencies: Vec<Dependency>

dependencies keeps track of direct dependencies of a given package. This too should be moved to fpm::Package to support recursive dependencies etc.

ignored: Override

ignored keeps track of files that are to be ignored by fpm build, fpm sync etc.

Implementations

build_dir is where the static built files are stored. fpm build command creates this folder and stores its output here.

history of a fpm package is stored in .history folder.

Current design is wrong, we should move this helper to fpm::Package maybe.

History of a package is considered part of the package, and when a package is downloaded we have to chose if we want to download its history as well. For now we do not. Eventually in we will be able to say download the history also for some package.

-- ftp.dependency: django
 with-history: true

.history file is created or updated by fpm sync command only, no one else should edit anything in it.

every package’s .history contains a file .latest.ftd. It looks a bit linke this:

-- import: fpm

-- fpm.snapshot: FPM.ftd
timestamp: 1638706756293421000

-- fpm.snapshot: blog.ftd
timestamp: 1638706756293421000

One fpm.snapshot for every file that is currently part of the package.

track_dir returns the directory where track files are stored. Tracking information as well is considered part of a package, but it is not downloaded when a package is downloaded as a dependency of another package.

is_translation_package() is a helper to tell you if the current package is a translation of another package. We may delete this helper soon.

original_path() returns the path of the original package if the current package is a translation package. it returns the path in .packages folder where the

aliases() returns the list of the available aliases at the package level.

get_font_style() returns the HTML style tag which includes all the fonts used by any ftd document. Currently this function does not check for fonts in package dependencies nor it tries to avoid fonts that are configured but not needed in current document.

read() is the way to read a Config.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more