1414
1515use crate :: golem_agentic:: golem:: agent:: common:: { ConfigKeyValueType , ConfigValueType } ;
1616use crate :: golem_agentic:: golem:: agent:: host:: get_config_value;
17- use golem_wasm:: { WitType } ;
18- use std:: marker:: PhantomData ;
1917use crate :: value_and_type:: { FromValueAndType , IntoValue } ;
2018use golem_wasm:: golem_rpc_0_2_x:: types:: ValueAndType ;
19+ use golem_wasm:: WitType ;
2120use std:: collections:: { BTreeMap , BTreeSet , HashMap , HashSet , LinkedList , VecDeque } ;
2221use std:: hash:: Hash ;
22+ use std:: marker:: PhantomData ;
23+ use std:: net:: IpAddr ;
24+ use std:: num:: {
25+ NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroI8 , NonZeroU16 , NonZeroU32 , NonZeroU64 , NonZeroU8 ,
26+ } ;
2327use std:: ops:: { Bound , Range } ;
24- use std:: num:: { NonZeroI8 , NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroU8 , NonZeroU16 , NonZeroU32 , NonZeroU64 } ;
25- use std:: time:: Duration ;
2628use std:: rc:: Rc ;
2729use std:: sync:: Arc ;
28- use std:: net :: IpAddr ;
30+ use std:: time :: Duration ;
2931
3032pub trait ConfigSchema : Sized {
3133 fn describe_config ( ) -> Vec < ConfigEntry > ;
@@ -50,7 +52,10 @@ impl<T> Secret<T> {
5052 T : FromValueAndType + IntoValue ,
5153 {
5254 let value = get_config_value ( & self . path ) ;
53- T :: from_value_and_type ( ValueAndType { value, typ : T :: get_type ( ) } )
55+ T :: from_value_and_type ( ValueAndType {
56+ value,
57+ typ : T :: get_type ( ) ,
58+ } )
5459 }
5560}
5661
@@ -77,12 +82,10 @@ impl From<ConfigEntry> for ConfigKeyValueType {
7782 }
7883}
7984
80- #[ diagnostic:: on_unimplemented(
81- message = "\
85+ #[ diagnostic:: on_unimplemented( message = "\
8286 `ConfigField` is not implemented for `{Self}`. Only types that implement `ConfigField` can be\n \
8387 used as part of an agent's config. If you tried to use a struct as part of the config, make sure\n \
84- it derives ConfigSchema.",
85- ) ]
88+ it derives ConfigSchema.") ]
8689pub trait ConfigField : Sized {
8790 const IS_SHARED : bool ;
8891
@@ -97,7 +100,7 @@ impl<T: IntoValue> ConfigField for Secret<T> {
97100 vec ! [ ConfigEntry {
98101 key: path_prefix. to_vec( ) ,
99102 shared: true ,
100- schema: T :: get_type( )
103+ schema: T :: get_type( ) ,
101104 } ]
102105 }
103106
@@ -122,12 +125,10 @@ impl<T: ComponentModelConfigLeaf> ConfigField for T {
122125
123126 fn load ( path : & [ String ] ) -> Result < Self , String > {
124127 let value = get_config_value ( path) ;
125- <Self as FromValueAndType >:: from_value_and_type (
126- ValueAndType {
127- value,
128- typ : <Self as IntoValue >:: get_type ( ) ,
129- }
130- )
128+ <Self as FromValueAndType >:: from_value_and_type ( ValueAndType {
129+ value,
130+ typ : <Self as IntoValue >:: get_type ( ) ,
131+ } )
131132 }
132133}
133134
@@ -228,25 +229,34 @@ macro_rules! impl_component_model_config_leaf_for_tuples {
228229
229230impl_component_model_config_leaf_for_tuples ! ( A , B , C , D , E , F , G , H , I , J , K , L ) ;
230231
231- impl < S : IntoValue + FromValueAndType , E : IntoValue + FromValueAndType > ComponentModelConfigLeaf for Result < S , E > { }
232+ impl < S : IntoValue + FromValueAndType , E : IntoValue + FromValueAndType > ComponentModelConfigLeaf
233+ for Result < S , E >
234+ {
235+ }
232236impl < E : IntoValue + FromValueAndType > ComponentModelConfigLeaf for Result < ( ) , E > { }
233237impl < S : IntoValue + FromValueAndType > ComponentModelConfigLeaf for Result < S , ( ) > { }
234- impl ComponentModelConfigLeaf for Result < ( ) , ( ) > { }
238+ impl ComponentModelConfigLeaf for Result < ( ) , ( ) > { }
235239
236- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Option < T > { }
237- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Bound < T > { }
238- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Range < T > { }
239- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Vec < T > { }
240- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for VecDeque < T > { }
241- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for LinkedList < T > { }
242- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Box < T > { }
243- impl < T : FromValueAndType + IntoValue + Clone > ComponentModelConfigLeaf for Rc < T > { }
244- impl < T : FromValueAndType + IntoValue + Clone > ComponentModelConfigLeaf for Arc < T > { }
240+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Option < T > { }
241+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Bound < T > { }
242+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Range < T > { }
243+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Vec < T > { }
244+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for VecDeque < T > { }
245+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for LinkedList < T > { }
246+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for Box < T > { }
247+ impl < T : FromValueAndType + IntoValue + Clone > ComponentModelConfigLeaf for Rc < T > { }
248+ impl < T : FromValueAndType + IntoValue + Clone > ComponentModelConfigLeaf for Arc < T > { }
245249
246- impl < T : FromValueAndType + IntoValue + Hash + Eq > ComponentModelConfigLeaf for HashSet < T > { }
247- impl < T : FromValueAndType + IntoValue + Ord > ComponentModelConfigLeaf for BTreeSet < T > { }
250+ impl < T : FromValueAndType + IntoValue + Hash + Eq > ComponentModelConfigLeaf for HashSet < T > { }
251+ impl < T : FromValueAndType + IntoValue + Ord > ComponentModelConfigLeaf for BTreeSet < T > { }
248252
249- impl < K : FromValueAndType + IntoValue + Hash + Eq , V : FromValueAndType + IntoValue > ComponentModelConfigLeaf for HashMap < K , V > { }
250- impl < K : FromValueAndType + IntoValue + Ord , V : FromValueAndType + IntoValue > ComponentModelConfigLeaf for BTreeMap < K , V > { }
253+ impl < K : FromValueAndType + IntoValue + Hash + Eq , V : FromValueAndType + IntoValue >
254+ ComponentModelConfigLeaf for HashMap < K , V >
255+ {
256+ }
257+ impl < K : FromValueAndType + IntoValue + Ord , V : FromValueAndType + IntoValue >
258+ ComponentModelConfigLeaf for BTreeMap < K , V >
259+ {
260+ }
251261
252- impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for nonempty_collections:: NEVec < T > { }
262+ impl < T : FromValueAndType + IntoValue > ComponentModelConfigLeaf for nonempty_collections:: NEVec < T > { }
0 commit comments