git_bot_feedback/
lib.rs

1#![doc = include_str!("../README.md")]
2pub mod client;
3pub mod error;
4
5use std::fmt::Display;
6
7pub use client::{RestApiClient, RestApiRateLimitHeaders};
8pub use error::RestClientError;
9mod thread_comments;
10pub use thread_comments::{CommentPolicy, ThreadCommentOptions};
11
12/// An enumeration of possible type of comments being posted.
13///
14/// The default is [`CommentKind::Concerns`].
15#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)]
16pub enum CommentKind {
17    /// A comment that admonishes concerns for end-users' attention.
18    #[default]
19    Concerns,
20
21    /// A comment that basically says "Looks Good To Me".
22    Lgtm,
23}
24
25/// A type to represent an output variable.
26///
27/// This is akin to the key/value pairs used in most
28/// config file formats but with some limitations:
29///
30/// - Both [OutputVariable::name] and [OutputVariable::value] must be UTF-8 encoded.
31/// - The [OutputVariable::value] cannot span multiple lines.
32#[derive(Debug, Clone)]
33pub struct OutputVariable {
34    /// The output variable's name.
35    pub name: String,
36
37    /// The output variable's value.
38    pub value: String,
39}
40
41impl OutputVariable {
42    pub(crate) fn validate(&self) -> bool {
43        !self.value.contains("\n")
44    }
45}
46
47impl Display for OutputVariable {
48    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49        write!(f, "{} = {}", self.name, self.value)
50    }
51}