-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the new config store hostcalls. (#296)
- Loading branch information
Showing
5 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;; Config Store ABI | ||
|
||
;;; A handle to an Config Store. | ||
(typename $config_store_handle (handle)) | ||
|
||
(module $fastly_config_store | ||
(@interface func (export "open") | ||
(param $name string) | ||
(result $err (expected $config_store_handle (error $fastly_status))) | ||
) | ||
|
||
(@interface func (export "get") | ||
(param $h $config_store_handle) | ||
(param $key string) | ||
(param $value (@witx pointer (@witx char8))) | ||
(param $value_max_len (@witx usize)) | ||
(result $err (expected $num_bytes (error $fastly_status))) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use super::{ | ||
fastly_config_store::FastlyConfigStore, | ||
types::{ConfigStoreHandle, DictionaryHandle}, | ||
}; | ||
use crate::{session::Session, wiggle_abi::fastly_dictionary::FastlyDictionary, Error}; | ||
use wiggle::GuestPtr; | ||
|
||
impl FastlyConfigStore for Session { | ||
fn open(&mut self, name: &GuestPtr<str>) -> Result<ConfigStoreHandle, Error> { | ||
let dict_answer = <Self as FastlyDictionary>::open(self, name)?; | ||
Ok(ConfigStoreHandle::from(unsafe { dict_answer.inner() })) | ||
} | ||
|
||
fn get( | ||
&mut self, | ||
config_store: ConfigStoreHandle, | ||
key: &GuestPtr<str>, | ||
buf: &GuestPtr<u8>, | ||
buf_len: u32, | ||
) -> Result<u32, Error> { | ||
let dict_handle = DictionaryHandle::from(unsafe { config_store.inner() }); | ||
<Self as FastlyDictionary>::get(self, dict_handle, key, buf, buf_len) | ||
} | ||
} |