Skip to content

Commit 5232dc5

Browse files
committed
Bump version to 1.0.1
1 parent 7c34e0e commit 5232dc5

4 files changed

Lines changed: 92 additions & 46 deletions

File tree

Cargo.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ffcv"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
edition = "2021"
55
authors = ["darkcodi <trooper982@gmail.com>"]
66
description = "Firefox Configuration Viewer - Parse and query Firefox preference files"

README.md

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ ffcv is both a command-line tool and a Rust library for working with Firefox's `
1919
- **Powerful Querying** - Filter preferences using glob patterns like `"network.*"` or `"browser.*.enabled"`
2020
- **Cross-Platform** - Automatic Firefox profile discovery on Linux, macOS, and Windows
2121
- **Rich Data Types** - Supports boolean, integer, float, string, and null values
22+
- **Type-Safe API** - Convenience trait for easy value type checking and extraction
23+
- **Simple Interface** - All public types and functions available at crate root
2224
- **Human-Readable Explanations** - Optional explanations for what preferences do
2325
- **Flexible Output** - JSON output with customizable formatting
2426
- **Well-Tested** - Comprehensive test coverage with robust error handling
@@ -41,7 +43,7 @@ Add to your `Cargo.toml`:
4143

4244
```toml
4345
[dependencies]
44-
ffcv = "1.0"
46+
ffcv = "1.0.1"
4547
```
4648

4749
## Command-Line Usage
@@ -87,12 +89,12 @@ ffcv config view default --file /path/to/prefs.js
8789
### Basic Parsing
8890

8991
```rust
90-
use ffcv::parser::parse_prefs;
92+
use ffcv::parse_prefs_js;
9193
use std::fs;
9294

9395
fn main() -> Result<(), Box<dyn std::error::Error>> {
9496
let content = fs::read_to_string("prefs.js")?;
95-
let entries = parse_prefs(&content)?;
97+
let entries = parse_prefs_js(&content)?;
9698

9799
for entry in entries {
98100
println!("{:?} = {:?}", entry.key, entry.value);
@@ -105,19 +107,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
105107
### Query Preferences
106108

107109
```rust
108-
use ffcv::parser::parse_prefs;
109-
use ffcv::query::QueryMatcher;
110+
use ffcv::{parse_prefs_js, query_preferences};
110111
use std::fs;
111112

112113
fn main() -> Result<(), Box<dyn std::error::Error>> {
113114
let content = fs::read_to_string("prefs.js")?;
114-
let entries = parse_prefs(&content)?;
115+
let entries = parse_prefs_js(&content)?;
115116

116-
// Create a matcher for network-related preferences
117-
let matcher = QueryMatcher::new(vec!["network.*"])?;
117+
// Query network-related preferences
118+
let network_prefs = query_preferences(&entries, &["network.*"])?;
118119

119-
// Filter and display matching entries
120-
for entry in entries.into_iter().filter(|e| matcher.matches(&e.key)) {
120+
// Display matching entries
121+
for entry in network_prefs {
121122
println!("{} = {:?}", entry.key, entry.value);
122123
}
123124

@@ -128,11 +129,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
128129
### Profile Discovery
129130

130131
```rust
131-
use ffcv::profile::ProfileFinder;
132+
use ffcv::list_profiles;
132133

133134
fn main() -> Result<(), Box<dyn std::error::Error>> {
134-
let finder = ProfileFinder::new()?;
135-
let profiles = finder.find_profiles()?;
135+
let profiles = list_profiles(None)?;
136136

137137
for profile in profiles {
138138
println!("Profile: {}", profile.name);
@@ -147,19 +147,61 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
147147
### Working with Preference Values
148148

149149
```rust
150-
use ffcv::types::{PrefEntry, PrefValue};
150+
use ffcv::{PrefEntry, PrefValue, PrefValueExt};
151151

152152
fn process_entry(entry: PrefEntry) {
153-
match entry.value {
154-
PrefValue::Bool(true) => println!("{} is enabled", entry.key),
155-
PrefValue::Bool(false) => println!("{} is disabled", entry.key),
156-
PrefValue::Int(n) => println!("{} = {} (integer)", entry.key, n),
157-
PrefValue::String(ref s) => println!("{} = \"{}\"", entry.key, s),
158-
_ => println!("{} = {:?}", entry.key, entry.value),
153+
// Use convenience methods from PrefValueExt trait
154+
if let Some(enabled) = entry.value.as_bool() {
155+
if enabled {
156+
println!("{} is enabled", entry.key);
157+
} else {
158+
println!("{} is disabled", entry.key);
159+
}
160+
} else if let Some(n) = entry.value.as_int() {
161+
println!("{} = {} (integer)", entry.key, n);
162+
} else if let Some(s) = entry.value.as_string() {
163+
println!("{} = \"{}\"", entry.key, s);
164+
} else {
165+
println!("{} = {:?}", entry.key, entry.value);
159166
}
160167
}
161168
```
162169

170+
### Finding a Specific Profile
171+
172+
```rust
173+
use ffcv::find_profile_path;
174+
175+
fn main() -> Result<(), Box<dyn std::error::Error>> {
176+
// Find a specific Firefox profile by name
177+
let profile_path = find_profile_path("default", None)?;
178+
179+
println!("Profile path: {}", profile_path.display());
180+
181+
Ok(())
182+
}
183+
```
184+
185+
## API Design
186+
187+
ffcv provides a clean, simplified API with all public types and functions available at the crate root:
188+
189+
**Core Types:**
190+
- `PrefEntry` - A single preference entry with key, value, and type
191+
- `PrefType` - The type of preference (User, Default, Locked, Sticky)
192+
- `PrefValue` - The value of a preference (Bool, Int, Float, String, Null)
193+
- `PrefValueExt` - Convenience trait for type-safe value access
194+
195+
**Core Functions:**
196+
- `parse_prefs_js()` - Parse preference file contents
197+
- `parse_prefs_js_file()` - Parse directly from a file path
198+
- `query_preferences()` - Filter preferences by glob patterns
199+
- `list_profiles()` - List all Firefox profiles
200+
- `find_profile_path()` - Find a specific profile by name
201+
- `get_prefs_path()` - Get the prefs.js path for a profile
202+
203+
All functions return `Result<T, Error>` for proper error handling.
204+
163205
## Preference Types
164206

165207
Firefox uses several types of preferences:
@@ -216,6 +258,10 @@ This project is dual-licensed under either:
216258

217259
You may choose either license for your use.
218260

261+
## Version 1.0
262+
263+
ffcv provides a stable and well-tested API. The library offers a clean, simplified interface with comprehensive Firefox preference parsing capabilities. All public types and functions are available at the crate root for easy importing.
264+
219265
## Acknowledgments
220266

221267
Built for the Rust community to make Firefox configuration management easier and more programmatic.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{
1515
packages.ffcv = pkgs.rustPlatform.buildRustPackage {
1616
pname = "ffcv";
17-
version = "1.0.0";
17+
version = "1.0.1";
1818
src = ./.;
1919
cargoLock.lockFile = ./Cargo.lock;
2020
buildType = "release";

0 commit comments

Comments
 (0)