Skip to content

Commit

Permalink
chore: fix compilation issue compiling Rust without default features #…
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Oct 5, 2023
1 parent c0201a7 commit 9946251
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ jobs:
- uses: actions/checkout@v3
- run: |
docker run --rm --user "$(id -u)":"$(id -g)" -v $(pwd):/workspace -w /workspace/rust -t -e TZ=UTC pactfoundation/rust-musl-build ./scripts/ci-musl-build.sh
check-features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo check --no-default-features
working-directory: rust

31 changes: 25 additions & 6 deletions rust/pact_consumer/src/builders/message_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ use crate::prelude::Pattern;

#[cfg(not(feature = "plugins"))]
#[derive(Clone, Debug, Default)]
struct InteractionContents {
/// Placeholder struct when plugins are disabled
pub struct InteractionContents {
/// Description of what part this interaction belongs to (in the case of there being more than
/// one, for instance, request/response messages)
#[allow(dead_code)] pub part_name: String,

/// Body/Contents of the interaction
pub body: OptionalBody,

Expand All @@ -39,16 +44,30 @@ struct InteractionContents {
pub generators: Option<Generators>,

/// Message metadata
pub metadata: Option<HashMap<String, Value>>
pub metadata: Option<HashMap<String, Value>>,

/// Matching rules to apply to message metadata
pub metadata_rules: Option<MatchingRuleCategory>,

/// Plugin configuration data to apply to the interaction
pub plugin_config: PluginConfiguration,

/// Markup for the interaction to display in any UI
pub interaction_markup: String,

/// The type of the markup (CommonMark or HTML)
pub interaction_markup_type: String
}

#[cfg(not(feature = "plugins"))]
#[derive(Clone, Debug)]
struct PactPluginManifest {}
#[derive(Clone, Debug, Default)]
/// Placeholder struct when plugins are disabled
pub struct PactPluginManifest {}

#[cfg(not(feature = "plugins"))]
#[derive(Clone, Debug)]
struct PluginConfiguration {}
#[derive(Clone, Debug, Default)]
/// Placeholder struct when plugins are disabled
pub struct PluginConfiguration {}

#[derive(Clone, Debug)]
/// Asynchronous message interaction builder. Normally created via PactBuilder::message_interaction.
Expand Down
34 changes: 5 additions & 29 deletions rust/pact_consumer/src/builders/sync_message_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,7 @@ use tracing::debug;
use crate::prelude::{JsonPattern, Pattern};
#[cfg(feature = "plugins")] use crate::prelude::PluginInteractionBuilder;

#[cfg(not(feature = "plugins"))]
#[derive(Clone, Debug, Default)]
struct InteractionContents {
/// Description of what part this interaction belongs to (in the case of there being more than
/// one, for instance, request/response messages)
#[allow(dead_code)] pub part_name: String,

/// Body/Contents of the interaction
pub body: OptionalBody,

/// Matching rules to apply
pub rules: Option<MatchingRuleCategory>,

/// Generators to apply
pub generators: Option<Generators>,

/// Message metadata
pub metadata: Option<HashMap<String, Value>>
}

#[cfg(not(feature = "plugins"))]
#[derive(Clone, Debug)]
struct PactPluginManifest {}

#[cfg(not(feature = "plugins"))]
#[derive(Clone, Debug)]
struct PluginConfiguration {}
#[cfg(not(feature = "plugins"))] use crate::builders::message_builder::{InteractionContents, PactPluginManifest, PluginConfiguration};

#[derive(Clone, Debug)]
/// Synchronous message interaction builder. Normally created via PactBuilder::sync_message_interaction.
Expand All @@ -60,8 +34,10 @@ pub struct SyncMessageInteractionBuilder {
test_name: Option<String>,
key: Option<String>,
pending: Option<bool>,
request_contents: InteractionContents, // TODO: This should not be using this struct, as it leaks plugin specific API
response_contents: Vec<InteractionContents>, // TODO: This should not be using this struct, as it leaks plugin specific API
/// Request contents of the message. This will include the payload as well as any metadata
pub request_contents: InteractionContents, // TODO: This should not be using this struct, as it leaks plugin specific API
/// Response contents of the message. This will include the payloads as well as any metadata
pub response_contents: Vec<InteractionContents>, // TODO: This should not be using this struct, as it leaks plugin specific API
#[allow(dead_code)] contents_plugin: Option<PactPluginManifest>,
#[allow(dead_code)] plugin_config: HashMap<String, PluginConfiguration>
}
Expand Down

0 comments on commit 9946251

Please sign in to comment.