#[non_exhaustive]pub struct FontSource {
pub repo_url: String,
pub config: PathBuf,
/* private fields */
}Expand description
Information about a font source in a git repository
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.repo_url: StringThe repository’s url
config: PathBufThe path to the config file for this font, relative to the repo root.
(if it is an external config, it is relative to the git cache root.)
Implementations§
Source§impl FontSource
impl FontSource
Sourcepub fn repo_org(&self) -> &str
pub fn repo_org(&self) -> &str
The name of the user or org that the repository lives under.
This is ‘googlefonts’ for the repo https://github.com/googlefonts/google-fonts-sources
Sourcepub fn repo_name(&self) -> &str
pub fn repo_name(&self) -> &str
The name of the repository.
This is everything after the trailing ‘/’ in e.g. https://github.com/PaoloBiagini/Joan
Sourcepub fn git_rev(&self) -> &str
pub fn git_rev(&self) -> &str
The commit rev of the repository’s main branch, at discovery time.
Sourcepub fn repo_path(&self, cache_dir: &Path) -> PathBuf
pub fn repo_path(&self, cache_dir: &Path) -> PathBuf
Given a root cache directory, return the local path this repo.
This is in the format, {cache_dir}/{repo_org}/{repo_name}
Sourcepub fn instantiate(&self, cache_dir: &Path) -> Result<PathBuf, LoadRepoError>
pub fn instantiate(&self, cache_dir: &Path) -> Result<PathBuf, LoadRepoError>
Attempt to checkout/update this repo to the provided cache_dir.
The repo will be checked out to ‘{cache_dir}/{repo_org}/{repo_name}’,
and HEAD will be set to the self.git_rev().
Returns the path to the checkout on success.
Returns an error if the repo cannot be cloned, the git rev cannot be found, or if there is an io error.
Sourcepub fn config_is_external(&self) -> bool
pub fn config_is_external(&self) -> bool
An ‘external’ config is one that does not exist in the source repository.
Instead it lives in the google/fonts repository, alongside the metadata file for this family.
The caller must figure out how to handle this. The actual config path can
be retrieved using the config_path method here.
Sourcepub fn config_path(&self, cache_dir: &Path) -> Result<PathBuf, LoadRepoError>
pub fn config_path(&self, cache_dir: &Path) -> Result<PathBuf, LoadRepoError>
Return path to the config file for this repo, if it exists.
Returns an error if the repo cannot be cloned, or if no config files are found.
Sourcepub fn get_sources(
&self,
git_cache_dir: &Path,
) -> Result<Vec<PathBuf>, LoadRepoError>
pub fn get_sources( &self, git_cache_dir: &Path, ) -> Result<Vec<PathBuf>, LoadRepoError>
Return a Vec of source files in this respository.
If necessary, this will create a new checkout of this repo at ‘{git_cache_dir}/{repo_org}/{repo_name}’.
Trait Implementations§
Source§impl Clone for FontSource
impl Clone for FontSource
Source§fn clone(&self) -> FontSource
fn clone(&self) -> FontSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontSource
impl Debug for FontSource
Source§impl<'de> Deserialize<'de> for FontSource
impl<'de> Deserialize<'de> for FontSource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for FontSource
impl Hash for FontSource
Source§impl Ord for FontSource
impl Ord for FontSource
Source§fn cmp(&self, other: &FontSource) -> Ordering
fn cmp(&self, other: &FontSource) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for FontSource
impl PartialEq for FontSource
Source§impl PartialOrd for FontSource
impl PartialOrd for FontSource
Source§impl Serialize for FontSource
impl Serialize for FontSource
impl Eq for FontSource
impl StructuralPartialEq for FontSource
Auto Trait Implementations§
impl Freeze for FontSource
impl RefUnwindSafe for FontSource
impl Send for FontSource
impl Sync for FontSource
impl Unpin for FontSource
impl UnwindSafe for FontSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.