Struct Config

Source
pub struct Config {
Show 26 fields pub version: String, pub origin: String, pub head: String, pub last_commit: String, pub branch: String, pub core_tap_json: String, pub core_cask_tap_json: String, pub prefix: String, pub api_domain: String, pub bottle_domain: String, pub brew_git_remote: String, pub cask_opts: Vec<String>, pub core_git_remote: String, pub editor: String, pub make_jobs: u32, pub pip_index_url: String, pub sorbet_runtime: String, pub ruby: String, pub cpu: String, pub clang: String, pub git: String, pub curl: String, pub macos: String, pub clt: String, pub xcode: String, pub rosetta2: bool,
}
Expand description

Config 的结构体

Fields§

§version: String§origin: String§head: String§last_commit: String§branch: String§core_tap_json: String§core_cask_tap_json: String§prefix: String§api_domain: String§bottle_domain: String§brew_git_remote: String§cask_opts: Vec<String>§core_git_remote: String§editor: String§make_jobs: u32§pip_index_url: String§sorbet_runtime: String§ruby: String§cpu: String§clang: String§git: String§curl: String§macos: String§clt: String§xcode: String§rosetta2: bool

Implementations§

Source§

impl Config

TODO: add display fn

Source

pub fn from(text: &str) -> Result<Self>

Examples

use homebrew;

let text = r#"
HOMEBREW_VERSION: 4.4.15-56-g6aac197
ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
HEAD: 6aac197d556f60e82490dcb46fcbe7090c8934e9
Last commit: 2 days ago
Branch: master
Core tap JSON: 10 Jan 14:49 UTC
Core cask tap JSON: 10 Jan 14:49 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_API_DOMAIN: https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
HOMEBREW_BREW_GIT_REMOTE: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 12
HOMEBREW_PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: dodeca-core 64-bit arm_brava
Clang: 16.0.0 build 1600
Git: 2.47.1 => /opt/homebrew/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.1-arm64
CLT: 16.2.0.0.1.1733547573
Xcode: N/A
Rosetta 2: false
"#;

let config = homebrew::Config::from(text).unwrap();

assert_eq!(config.version, "4.4.15-56-g6aac197");
assert_eq!(config.origin, "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git");
assert_eq!(config.last_commit, "2 days ago");
assert_eq!(config.head, "6aac197d556f60e82490dcb46fcbe7090c8934e9");
assert_eq!(config.branch, "master");
assert_eq!(config.core_tap_json, "10 Jan 14:49 UTC");
assert_eq!(config.core_cask_tap_json, "10 Jan 14:49 UTC");
assert_eq!(config.prefix, "/opt/homebrew");
assert_eq!(config.api_domain, "https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api");
assert_eq!(config.bottle_domain, "https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles");
assert_eq!(config.brew_git_remote, "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git");
assert_eq!(config.cask_opts, Vec::<String>::new());
assert_eq!(config.core_git_remote, "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git");
assert_eq!(config.editor, "nvim");
assert_eq!(config.make_jobs, 12);
assert_eq!(config.pip_index_url, "https://pypi.tuna.tsinghua.edu.cn/simple");
assert_eq!(config.sorbet_runtime, "set");
assert_eq!(config.ruby, "3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby");
assert_eq!(config.cpu, "dodeca-core 64-bit arm_brava");
assert_eq!(config.clang, "16.0.0 build 1600");
assert_eq!(config.git, "2.47.1 => /opt/homebrew/bin/git");
assert_eq!(config.curl, "8.7.1 => /usr/bin/curl");
assert_eq!(config.macos, "15.1-arm64");
assert_eq!(config.clt, "16.2.0.0.1.1733547573");
assert_eq!(config.xcode, "N/A");
assert_eq!(config.rosetta2, false);

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,