pub struct SelectOption<T = Value>{
pub value: T,
pub label: String,
pub description: Option<String>,
}Expand description
An option in a StandardRequest::Select request.
Each option has:
- value: Machine-readable identifier returned in the response (generic over
T) - label: Human-readable text displayed to the user
- description: Optional additional context about the option
The type parameter T defaults to serde_json::Value for backwards compatibility.
§Wire Format
{
"value": "prod",
"label": "Production",
"description": "Live environment - requires approval"
}§Example
use plexus_core::plexus::bidirectional::SelectOption;
let options = vec![
SelectOption::new("minimal", "Minimal Starter")
.with_description("Basic project structure"),
SelectOption::new("full", "Full Featured")
.with_description("All features included"),
SelectOption::new("api", "API Only"), // No description
];Fields§
§value: TMachine-readable value returned when this option is selected.
This is what appears in StandardResponse::Selected.
Should be a stable identifier (e.g., “dev”, “prod”, “option_1”).
label: StringHuman-readable label displayed to the user.
Should be concise but descriptive (e.g., “Development”, “Production”).
description: Option<String>Optional description providing additional context.
Use for longer explanations that don’t fit in the label. Clients may display this as a tooltip or secondary text.
Implementations§
Source§impl SelectOption
impl SelectOption
Sourcepub fn new(value: impl Into<Value>, label: impl Into<String>) -> SelectOption
pub fn new(value: impl Into<Value>, label: impl Into<String>) -> SelectOption
Create a new select option with value and label.
This constructor is for the default T = serde_json::Value type.
The value parameter is converted to serde_json::Value via .into().
§Arguments
value- Machine-readable identifier (returned in response), convertible toserde_json::Valuelabel- Human-readable display text
§Example
use plexus_core::plexus::bidirectional::SelectOption;
let opt = SelectOption::new("dev", "Development Environment");
assert_eq!(opt.label, "Development Environment");Sourcepub fn with_description(self, desc: impl Into<String>) -> SelectOption
pub fn with_description(self, desc: impl Into<String>) -> SelectOption
Add a description to this option.
§Example
use plexus_core::plexus::bidirectional::SelectOption;
let opt = SelectOption::new("prod", "Production")
.with_description("Live environment - changes affect real users");
assert_eq!(opt.description, Some("Live environment - changes affect real users".into()));Source§impl<T> SelectOption<T>
impl<T> SelectOption<T>
Sourcepub fn new_typed(value: T, label: impl Into<String>) -> SelectOption<T>
pub fn new_typed(value: T, label: impl Into<String>) -> SelectOption<T>
Create a new select option with a typed value and label.
Use this constructor when working with a custom type T.
§Arguments
value- The typed value for this optionlabel- Human-readable display text
Sourcepub fn with_description_typed(self, desc: impl Into<String>) -> SelectOption<T>
pub fn with_description_typed(self, desc: impl Into<String>) -> SelectOption<T>
Add a description to this option.
Trait Implementations§
Source§impl<T> Clone for SelectOption<T>
impl<T> Clone for SelectOption<T>
Source§fn clone(&self) -> SelectOption<T>
fn clone(&self) -> SelectOption<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for SelectOption<T>
impl<T> Debug for SelectOption<T>
Source§impl<'de, T> Deserialize<'de> for SelectOption<T>
impl<'de, T> Deserialize<'de> for SelectOption<T>
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SelectOption<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SelectOption<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<T> JsonSchema for SelectOption<T>
impl<T> JsonSchema for SelectOption<T>
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl<T> PartialEq for SelectOption<T>
impl<T> PartialEq for SelectOption<T>
Source§impl<T> Serialize for SelectOption<T>
impl<T> Serialize for SelectOption<T>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<T> StructuralPartialEq for SelectOption<T>
Auto Trait Implementations§
impl<T> Freeze for SelectOption<T>where
T: Freeze,
impl<T> RefUnwindSafe for SelectOption<T>where
T: RefUnwindSafe,
impl<T> Send for SelectOption<T>where
T: Send,
impl<T> Sync for SelectOption<T>where
T: Sync,
impl<T> Unpin for SelectOption<T>where
T: Unpin,
impl<T> UnsafeUnpin for SelectOption<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for SelectOption<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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