Struct Commit

Source
pub struct Commit {
    pub title: String,
    pub description: String,
}

Fieldsยง

ยงtitle: String

The title of the commit.

ยงdescription: String

An exhaustive description of the changes.

Implementationsยง

Sourceยง

impl Commit

Source

pub fn new(title: String, description: String) -> Self

Examples found in repository?
examples/basic_usage.rs (lines 12-15)
10fn main() {
11    // Example of creating a commit struct
12    let commit = Commit::new(
13        "feat: add basic usage example".to_string(),
14        "This example demonstrates how to use noob-commit programmatically and shows the basic structure of commit messages.".to_string(),
15    );
16
17    println!("Example commit title: {}", commit.title);
18    println!("Example commit description: {}", commit.description);
19    println!("\nFull commit message:\n{}", commit.to_string());
20
21    // Example of checking for API key
22    match env::var("OPENAI_API_KEY") {
23        Ok(_) => println!("โœ… OpenAI API key is set"),
24        Err(_) => println!("โŒ OpenAI API key is not set. Set OPENAI_API_KEY environment variable"),
25    }
26
27    println!("\nTo use noob-commit:");
28    println!("1. Stage your changes: git add .");
29    println!("2. Run: noob-commit");
30    println!("3. Or for dry run: noob-commit --dry-run");
31    println!("4. To review before commit: noob-commit --review");
32}
More examples
Hide additional examples
examples/mock_commit.rs (lines 13-16)
10fn main() {
11    // Example commit messages for different scenarios
12    let commit_examples = vec![
13        Commit::new(
14            "feat: add user authentication system".to_string(),
15            "Implemented OAuth2 authentication with support for Google and GitHub providers. Added JWT token generation and validation for secure session management.".to_string(),
16        ),
17        Commit::new(
18            "fix: resolve memory leak in cache handler".to_string(),
19            "Fixed memory leak caused by unreleased references in the LRU cache implementation. Added proper cleanup in the destructor and improved memory management.".to_string(),
20        ),
21        Commit::new(
22            "docs: update API documentation with new endpoints".to_string(),
23            "Added comprehensive documentation for the new REST API endpoints including request/response examples, authentication requirements, and error codes.".to_string(),
24        ),
25        Commit::new(
26            "refactor: improve error handling in database module".to_string(),
27            "Refactored database error handling to use Result types consistently. Added custom error types for better error propagation and debugging.".to_string(),
28        ),
29        Commit::new(
30            "test: add unit tests for payment processing".to_string(),
31            "Added comprehensive unit tests for payment processing module covering edge cases, error scenarios, and successful payment flows.".to_string(),
32        ),
33    ];
34
35    println!("Example commit messages:");
36    println!("========================");
37    
38    for (i, commit) in commit_examples.iter().enumerate() {
39        println!("\n{}. Title: {}", i + 1, commit.title);
40        println!("   Description: {}", commit.description);
41    }
42    
43    println!("\nThese are examples of well-formatted commit messages that follow conventional commit standards.");
44    println!("When using noob-commit, the AI will generate similar messages based on your staged changes.");
45}

Trait Implementationsยง

Sourceยง

impl Debug for Commit

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<'de> Deserialize<'de> for Commit

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 JsonSchema for Commit

Sourceยง

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Sourceยง

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Sourceยง

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Sourceยง

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Sourceยง

fn always_inline_schema() -> bool

๐Ÿ‘ŽDeprecated: Use inline_schema() instead
Only included for backward-compatibility - use inline_schema() insteadโ€œ. Read more
Sourceยง

impl Serialize for Commit

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
Sourceยง

impl ToString for Commit

Sourceยง

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementationsยง

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> 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, 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>,