Crate bug

Crate bug 

Source
Expand description

§Bug Reporting Library

A Rust library for generating GitHub issue URLs with customizable templates. Supports both std and no_std environments, making it suitable for embedded systems, WebAssembly, and other constrained environments.

§Features

  • Template-based bug reporting: Define reusable issue templates with placeholders
  • GitHub integration: Generate direct links to GitHub’s new issue page
  • no_std support: Works in embedded and constrained environments
  • Terminal hyperlinks: Smart hyperlink detection for modern terminals
  • Flexible output: Customizable output destinations

§Quick Start

§Global Configuration (std only)

use bug::{init, bug, IssueTemplate};
 
// Initialize with your GitHub repository
init("username", "repository")
    .add_template("crash", IssueTemplate::new(
        "Application Crash: {error_type}",
        "The application crashed with error: {error_message}\n\nSteps to reproduce:\n{steps}"
    ))
    .build()
    .expect("Failed to initialize bug reporting");
 
// Use the bug! macro to report issues
let url = bug!("crash", {
    error_type = "NullPointerException",
    error_message = "Attempted to access null pointer",
    steps = "1. Start app\n2. Click button\n3. Crash occurs"
});

§Handle-based API (std and no_std)

use bug::{init_handle, bug_with_handle, IssueTemplate};
 
let handle = init_handle("username", "repository")
    .add_template("bug", IssueTemplate::new("Bug Report", "Found a bug: {description}"));
 
let url = bug_with_handle!(handle, "bug", {
    description = "Button doesn't work"
});

Modules§

url_encode
URL encoding utilities for no_std compatibility.

Macros§

bug
Report a bug using the global configuration (std only).
bug_with_handle
Report a bug using a specific handle (works in both std and no_std).
template_file
Macro to create a TemplateFile from a file path at compile time.

Structs§

BugReportConfig
Configuration for the bug reporting system.
BugReportConfigBuilder
Builder for configuring the global bug reporting system (std only).
BugReportHandle
A handle for bug reporting that doesn’t rely on global state.
IssueTemplate
A GitHub issue template with title, body, and labels.
NoOutput
A no-op output implementation that discards all output.
TemplateFile
A template loaded from a static string (typically from include_str!).

Enums§

HyperlinkMode
Controls how hyperlinks are displayed in terminal output.

Traits§

Output
Trait for outputting bug report information in no_std environments.

Functions§

create_terminal_hyperlink
Create a clickable terminal hyperlink using ANSI escape sequences.
extract_placeholders
Extract placeholder names from template content.
generate_github_url
Generate a GitHub issue URL using the global configuration (std only).
get_hyperlink_mode
Get the hyperlink mode from the global configuration (std only).
init
Initialize a bug report configuration builder (std only).
init_handle
Initialize a bug report handle (works in both std and no_std).
supports_hyperlinks
Detect if the current terminal supports clickable hyperlinks (std only).

Type Aliases§

FxHashMap
A fast HashMap implementation using FxHasher.