pub struct ParamResolver<'a> { /* private fields */ }Expand description
Action パラメータ解決ヘルパー
Environment がアクションパラメータを取得する際の共通パターンを提供する。
args[key] と target の優先順位を統一し、空文字列の扱いを正規化する。
§Example
ⓘ
fn handle_read_logs(&self, action: &Action) -> WorkResult {
let resolver = ParamResolver::new(action);
// 必須パラメータ: なければエラー
let service = match resolver.require("service") {
Ok(s) => s,
Err(e) => return WorkResult::env_failure(e.to_string()),
};
// オプショナルパラメータ
let limit = resolver.get("limit");
// ...
}Implementations§
Source§impl<'a> ParamResolver<'a>
impl<'a> ParamResolver<'a>
Sourcepub fn get_target_first(&self, key: &str) -> Option<&str>
pub fn get_target_first(&self, key: &str) -> Option<&str>
target を優先して取得(なければ args[key] をフォールバック)
LLM が target フィールドにパラメータを入れる場合に使用。
§Arguments
key- フォールバック用のパラメータ名
Sourcepub fn require_target_first(
&self,
key: &str,
) -> Result<&str, ActionValidationError>
pub fn require_target_first( &self, key: &str, ) -> Result<&str, ActionValidationError>
target を優先して必須パラメータを取得
Sourcepub fn action_name(&self) -> &str
pub fn action_name(&self) -> &str
Action 名を取得
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ParamResolver<'a>
impl<'a> RefUnwindSafe for ParamResolver<'a>
impl<'a> Send for ParamResolver<'a>
impl<'a> Sync for ParamResolver<'a>
impl<'a> Unpin for ParamResolver<'a>
impl<'a> UnwindSafe for ParamResolver<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more