Skip to content

Commit

Permalink
Contexts are now actually deserializable
Browse files Browse the repository at this point in the history
  • Loading branch information
Lut99 committed Dec 2, 2024
1 parent 9edf316 commit 8ca01dd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
26 changes: 13 additions & 13 deletions lib/reasoners/eflint-json/src/reasonerconn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created:
// 09 Oct 2024, 15:52:06
// Last edited:
// 02 Dec 2024, 14:32:35
// 02 Dec 2024, 15:49:51
// Auto updated?
// Yes
//
Expand Down Expand Up @@ -121,35 +121,35 @@ pub enum Error<R, S, Q> {

/***** AUXILLARY *****/
/// Defines the context for the eFLINT reasoner.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EFlintJsonReasonerContext {
/// The version of the reasoner.
pub version: &'static str,
pub version: String,
/// The language identifier of the reasoner.
pub language: &'static str,
pub language: String,
/// The language version identifier of the reasoner.
pub language_version: &'static str,
pub language_version: String,
}
impl Default for EFlintJsonReasonerContext {
#[inline]
fn default() -> Self { Self { version: env!("CARGO_PKG_VERSION"), language: "eflint-json", language_version: "0.1.0-srv" } }
fn default() -> Self { Self { version: env!("CARGO_PKG_VERSION").into(), language: "eflint-json".into(), language_version: "0.1.0-srv".into() } }
}
impl ReasonerContext for EFlintJsonReasonerContext {
#[inline]
fn version(&self) -> Cow<str> { Cow::Borrowed(self.version) }
fn version(&self) -> Cow<str> { Cow::Borrowed(&self.version) }

#[inline]
fn language(&self) -> Cow<str> { Cow::Borrowed(self.language) }
fn language(&self) -> Cow<str> { Cow::Borrowed(&self.language) }

#[inline]
fn language_version(&self) -> Cow<str> { Cow::Borrowed(self.language_version) }
fn language_version(&self) -> Cow<str> { Cow::Borrowed(&self.language_version) }
}

/// Defines a slightly more elaborate context for the eFLINT reasoner that's relevant for private
/// use, but not for public.
///
/// Mostly exists for logging to the audit log.
#[derive(Clone, Copy, Debug, Serialize)]
#[derive(Clone, Debug, Serialize)]
pub struct EFlintJsonReasonerContextFull<'a> {
/// The normal context
pub context: EFlintJsonReasonerContext,
Expand All @@ -169,13 +169,13 @@ impl<'a> EFlintJsonReasonerContextFull<'a> {
}
impl<'a> ReasonerContext for EFlintJsonReasonerContextFull<'a> {
#[inline]
fn version(&self) -> Cow<str> { Cow::Borrowed(self.context.version) }
fn version(&self) -> Cow<str> { Cow::Borrowed(&self.context.version) }

#[inline]
fn language(&self) -> Cow<str> { Cow::Borrowed(self.context.language) }
fn language(&self) -> Cow<str> { Cow::Borrowed(&self.context.language) }

#[inline]
fn language_version(&self) -> Cow<str> { Cow::Borrowed(self.context.language_version) }
fn language_version(&self) -> Cow<str> { Cow::Borrowed(&self.context.language_version) }
}


Expand Down
18 changes: 9 additions & 9 deletions lib/reasoners/no-op/src/reasonerconn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created:
// 10 Oct 2024, 16:21:09
// Last edited:
// 02 Dec 2024, 14:33:59
// 02 Dec 2024, 15:49:08
// Auto updated?
// Yes
//
Expand Down Expand Up @@ -57,28 +57,28 @@ pub enum Error {

/***** AUXILLARY *****/
/// The [`ReasonerContext`] returned by the [`NoOpReasonerConnector`].
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct NoOpReasonerContext {
/// The version of this reasoner.
pub version: &'static str,
pub version: String,
/// The language identifier of this reasoner.
pub language: &'static str,
pub language: String,
/// The language's version identifier of this reasoner.
pub language_version: &'static str,
pub language_version: String,
}
impl Default for NoOpReasonerContext {
#[inline]
fn default() -> Self { Self { version: env!("CARGO_PKG_VERSION"), language: "no-op", language_version: "v1" } }
fn default() -> Self { Self { version: env!("CARGO_PKG_VERSION").into(), language: "no-op".into(), language_version: "v1".into() } }
}
impl ReasonerContext for NoOpReasonerContext {
#[inline]
fn version(&self) -> Cow<str> { Cow::Borrowed(self.version) }
fn version(&self) -> Cow<str> { Cow::Borrowed(&self.version) }

#[inline]
fn language(&self) -> Cow<str> { Cow::Borrowed(self.language) }
fn language(&self) -> Cow<str> { Cow::Borrowed(&self.language) }

#[inline]
fn language_version(&self) -> Cow<str> { Cow::Borrowed(self.language_version) }
fn language_version(&self) -> Cow<str> { Cow::Borrowed(&self.language_version) }
}


Expand Down
18 changes: 9 additions & 9 deletions lib/reasoners/posix/src/reasonerconn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created:
// 11 Oct 2024, 16:54:51
// Last edited:
// 02 Dec 2024, 14:28:32
// 02 Dec 2024, 15:48:38
// Auto updated?
// Yes
//
Expand Down Expand Up @@ -216,28 +216,28 @@ impl BitOr<Self> for PosixFilePermission {

/***** AUXILLARY *****/
/// The [`ReasonerContext`] returned by the [`PosixReasonerConnector`].
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PosixReasonerContext {
/// The version of this reasoner.
pub version: &'static str,
pub version: String,
/// The language identifier of this reasoner.
pub language: &'static str,
pub language: String,
/// The language's version identifier of this reasoner.
pub language_version: &'static str,
pub language_version: String,
}
impl Default for PosixReasonerContext {
#[inline]
fn default() -> Self { Self { version: env!("CARGO_PKG_VERSION"), language: "posix", language_version: "0.2.0" } }
fn default() -> Self { Self { version: env!("CARGO_PKG_VERSION").into(), language: "posix".into(), language_version: "0.2.0".into() } }
}
impl ReasonerContext for PosixReasonerContext {
#[inline]
fn version(&self) -> Cow<str> { Cow::Borrowed(self.version) }
fn version(&self) -> Cow<str> { Cow::Borrowed(&self.version) }

#[inline]
fn language(&self) -> Cow<str> { Cow::Borrowed(self.language) }
fn language(&self) -> Cow<str> { Cow::Borrowed(&self.language) }

#[inline]
fn language_version(&self) -> Cow<str> { Cow::Borrowed(self.language_version) }
fn language_version(&self) -> Cow<str> { Cow::Borrowed(&self.language_version) }
}

/// The overarching input to the POSIX reasoner.
Expand Down

0 comments on commit 8ca01dd

Please sign in to comment.