Skip to content

Commit d341f2a

Browse files
authored
feat(unstable): Make constructing SessionConfigSelects on the Rust side nicer (#343)
1 parent c12410f commit d341f2a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/agent.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,20 @@ pub enum SessionConfigSelectOptions {
15131513
Grouped(Vec<SessionConfigSelectGroup>),
15141514
}
15151515

1516+
#[cfg(feature = "unstable_session_config_options")]
1517+
impl From<Vec<SessionConfigSelectOption>> for SessionConfigSelectOptions {
1518+
fn from(options: Vec<SessionConfigSelectOption>) -> Self {
1519+
SessionConfigSelectOptions::Ungrouped(options)
1520+
}
1521+
}
1522+
1523+
#[cfg(feature = "unstable_session_config_options")]
1524+
impl From<Vec<SessionConfigSelectGroup>> for SessionConfigSelectOptions {
1525+
fn from(groups: Vec<SessionConfigSelectGroup>) -> Self {
1526+
SessionConfigSelectOptions::Grouped(groups)
1527+
}
1528+
}
1529+
15161530
/// **UNSTABLE**
15171531
///
15181532
/// This capability is not part of the spec yet, and may be removed or changed at any point.
@@ -1534,11 +1548,11 @@ impl SessionConfigSelect {
15341548
#[must_use]
15351549
pub fn new(
15361550
current_value: impl Into<SessionConfigValueId>,
1537-
options: SessionConfigSelectOptions,
1551+
options: impl Into<SessionConfigSelectOptions>,
15381552
) -> Self {
15391553
Self {
15401554
current_value: current_value.into(),
1541-
options,
1555+
options: options.into(),
15421556
}
15431557
}
15441558
}
@@ -1609,7 +1623,7 @@ impl SessionConfigOption {
16091623
id: impl Into<SessionConfigId>,
16101624
name: impl Into<String>,
16111625
current_value: impl Into<SessionConfigValueId>,
1612-
options: SessionConfigSelectOptions,
1626+
options: impl Into<SessionConfigSelectOptions>,
16131627
) -> Self {
16141628
Self::new(
16151629
id,

0 commit comments

Comments
 (0)