Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change naming convention for logcraft plugin wit interface #5

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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