Skip to content

Commit

Permalink
feat: change naming convention for logcraft plugin wit interface (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatisseB authored Jun 25, 2024
1 parent 74c9d09 commit 1e87530
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
18 changes: 0 additions & 18 deletions crates/common/src/parser.rs

This file was deleted.

24 changes: 12 additions & 12 deletions crates/common/src/plugins/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use anyhow::{anyhow, bail, Result};
use async_trait::async_trait;
use logcraft_runtime::{
plugin_component::plugin::Metadata, state::State, Config, Engine, Interfaces,
plugin_component::plugin::Metadata, state::State, Config, Engine, Plugins,
DEFAULT_EPOCH_TICK_INTERVAL,
};
use serde::{Deserialize, Serialize};
Expand All @@ -22,7 +22,7 @@ use crate::plugins::cleanup_plugin;
use super::LGC_PLUGINS_PATH;

pub struct InstanceData {
interface: Interfaces,
interface: Plugins,
pub metadata: Metadata,
}

Expand Down Expand Up @@ -85,10 +85,10 @@ impl PluginManager {
);

let (interface, _) =
Interfaces::instantiate_async(&mut store, &component, &self.engine.linker).await?;
Plugins::instantiate_async(&mut store, &component, &self.engine.linker).await?;

let metadata = interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_load(&mut store)
.await?;

Expand Down Expand Up @@ -143,19 +143,19 @@ pub trait PluginActions: Send + 'static {
#[async_trait]
impl PluginActions for InstanceData {
async fn load(&self, store: &mut Store<State>) -> Result<Metadata> {
self.interface.logcraft_host_plugin().call_load(store).await
self.interface.logcraft_lgc_plugin().call_load(store).await
}

async fn settings(&self, store: &mut Store<State>) -> Result<String> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_settings(store)
.await
}

async fn schema(&self, store: &mut Store<State>) -> Result<String> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_schema(store)
.await
}
Expand All @@ -168,7 +168,7 @@ impl PluginActions for InstanceData {
params: &str,
) -> Result<Option<String>> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_create(store, config, name, params)
.await
.map_err(|e| {
Expand All @@ -195,7 +195,7 @@ impl PluginActions for InstanceData {
params: &str,
) -> Result<Option<String>> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_read(store, config, name, params)
.await?
.map_err(|e| {
Expand All @@ -215,7 +215,7 @@ impl PluginActions for InstanceData {
params: &str,
) -> Result<Option<String>> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_update(store, config, name, params)
.await?
.map_err(|e| {
Expand All @@ -235,7 +235,7 @@ impl PluginActions for InstanceData {
params: &str,
) -> Result<Option<String>> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_delete(store, config, name, params)
.await?
.map_err(|e| {
Expand All @@ -249,7 +249,7 @@ impl PluginActions for InstanceData {

async fn ping(&self, store: &mut Store<State>, config: &str) -> Result<bool> {
self.interface
.logcraft_host_plugin()
.logcraft_lgc_plugin()
.call_ping(store, config)
.await?
.map_err(|e| {
Expand Down
4 changes: 2 additions & 2 deletions crates/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ wasmtime::component::bindgen!({
});

pub mod plugin_component {
pub use crate::exports::logcraft::host::plugin;
pub use crate::Interfaces;
pub use crate::exports::logcraft::lgc::plugin;
pub use crate::Plugins;
}
4 changes: 2 additions & 2 deletions wit/world.wit
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) 2023 LogCraft, SAS.
// SPDX-License-Identifier: MPL-2.0

package logcraft:host;
package logcraft:lgc@0.1.0;

/// The logcraft world for the component to target.
world interfaces {
world plugins {
// Imports

// Exports
Expand Down

0 comments on commit 1e87530

Please sign in to comment.