pub async fn load_component(&self, id: &str) -> Result<Component> {
        let id = id.to_lowercase();

        info!("loading component '{}'", id);
        let mut url = self.config.get_string("base-url")?;
        if !url.ends_with('/') {
            url += "/";
        }

        if let Some(_manufacturer) = self.manufacturer(&id) {
            // TODO: Get common manufacturer info from README.rst
        }
        url += &self.file_path(&id);
        debug!("URL: {}", url);
        let component_yaml = self
            .get_url_contents(&url)
            .await
            .with_context(|| "component loading failed")?;
        let component = self.parse_component(&id, &component_yaml)?;

        let dir = self.local_dir(&id);
        fs::create_dir_all(&dir)?;
        let component_path = self.local_path(&id);
        debug!("path: {}", component_path);
        fs::write(component_path, component_yaml)?;

        Ok(component)
    }
/// Loads component config from remote repository.
///
/// # Examples
///
/// ```
/// use qeda::library::Library;
///
/// let lib = Library::new();
/// let mut rt = tokio::runtime::Runtime::new().unwrap();
/// rt.block_on(lib.load_component("capacitor/c0603")).unwrap();
/// ```
Loads component config from remote repository.
Loads component config from remote repository .
pub async fn load_component(&self, id: &str) -> Result<Component> {
        let id = id.to_lowercase();
        info!("loading component '{}'", id);
        let mut url = self.config.get_string("base-url")?;
        if !url.ends_with('/') {
            url += "/";
        }
        if let Some(_manufacturer) = self.manufacturer(&id) {
            // TODO: Get common manufacturer info from README.rst
        }
        url += &self.file_path(&id);
        debug!("URL: {}", url);
        let component_yaml = self
            .get_url_contents(&url)
            .await
            .with_context(|| "component loading failed")?;
        let component = self.parse_component(&id, &component_yaml)?;
        let dir = self.local_dir(&id);
        fs::create_dir_all(&dir)?;
        let component_path = self.local_path(&id);
        debug!("path: {}", component_path);
        fs::write(component_path, component_yaml)?;
        Ok(component)
    }
pub async fn load_component ( & self , id : & str ) -> Result < Component > { let id = id . to_lowercase ( ) ; info ! ( " " id ) ; let mut url = self . config . get_string ( " " ) ? ; if ! url . ends_with ( '/' ) { url += " " ; } if let Some ( _manufacturer ) = self . manufacturer ( & id ) { // TODO: Get common manufacturer info from README.rst } url += & self . file_path ( & id ) ; debug ! ( " " url ) ; let component_yaml = self . get_url_contents ( & url ) . await . with_context ( | | " " ) ? ; let component = self . parse_component ( & id , & component_yaml ) ? ; let dir = self . local_dir ( & id ) ; fs :: create_dir_all ( & dir ) ? ; let component_path = self . local_path ( & id ) ; debug ! ( " " component_path ) ; fs :: write ( component_path , component_yaml ) ? ; Ok ( component ) }
Loads component config from remote repository.
Loads component config from remote repository .
&self
id
&str
&self
id
&str
examples
```
use qeda::library::Library.

let lib = Library::new();
let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(lib.load_component("capacitor/c0603")).unwrap();
```
` ` ` use qeda :: library :: Library . let lib = Library :: new () ; let mut rt = tokio :: runtime :: Runtime :: new () . unwrap () ; rt . block_on ( lib . load_component ( " capacitor / c0603 " )) . unwrap () ; ` ` `