MenuItem

Struct MenuItem 

Source
pub struct MenuItem {
    pub action: Option<String>,
    pub contextual_command: Option<String>,
    pub id: Option<String>,
    pub payload: Option<String>,
    pub remove_when_selected: Option<bool>,
    pub values: Option<Vec<MenuValue>>,
}
Expand description

A custom menu item that can be presented to the user by a timeline item.

This type is not used in any activity, and only used as part of another schema.

Fields§

§action: Option<String>

Controls the behavior when the user picks the menu option. Allowed values are:

  • CUSTOM - Custom action set by the service. When the user selects this menuItem, the API triggers a notification to your callbackUrl with the userActions.type set to CUSTOM and the userActions.payload set to the ID of this menu item. This is the default value.
  • Built-in actions:
  • REPLY - Initiate a reply to the timeline item using the voice recording UI. The creator attribute must be set in the timeline item for this menu to be available.
  • REPLY_ALL - Same behavior as REPLY. The original timeline item’s recipients will be added to the reply item.
  • DELETE - Delete the timeline item.
  • SHARE - Share the timeline item with the available contacts.
  • READ_ALOUD - Read the timeline item’s speakableText aloud; if this field is not set, read the text field; if none of those fields are set, this menu item is ignored.
  • GET_MEDIA_INPUT - Allow users to provide media payloads to Glassware from a menu item (currently, only transcribed text from voice input is supported). Subscribe to notifications when users invoke this menu item to receive the timeline item ID. Retrieve the media from the timeline item in the payload property.
  • VOICE_CALL - Initiate a phone call using the timeline item’s creator.phoneNumber attribute as recipient.
  • NAVIGATE - Navigate to the timeline item’s location.
  • TOGGLE_PINNED - Toggle the isPinned state of the timeline item.
  • OPEN_URI - Open the payload of the menu item in the browser.
  • PLAY_VIDEO - Open the payload of the menu item in the Glass video player.
  • SEND_MESSAGE - Initiate sending a message to the timeline item’s creator:
  • If the creator.phoneNumber is set and Glass is connected to an Android phone, the message is an SMS.
  • Otherwise, if the creator.email is set, the message is an email.
§contextual_command: Option<String>

The ContextualMenus.Command associated with this MenuItem (e.g. READ_ALOUD). The voice label for this command will be displayed in the voice menu and the touch label will be displayed in the touch menu. Note that the default menu value’s display name will be overriden if you specify this property. Values that do not correspond to a ContextualMenus.Command name will be ignored.

§id: Option<String>

The ID for this menu item. This is generated by the application and is treated as an opaque token.

§payload: Option<String>

A generic payload whose meaning changes depending on this MenuItem’s action.

  • When the action is OPEN_URI, the payload is the URL of the website to view.
  • When the action is PLAY_VIDEO, the payload is the streaming URL of the video
  • When the action is GET_MEDIA_INPUT, the payload is the text transcription of a user’s speech input
§remove_when_selected: Option<bool>

If set to true on a CUSTOM menu item, that item will be removed from the menu after it is selected.

§values: Option<Vec<MenuValue>>

For CUSTOM items, a list of values controlling the appearance of the menu item in each of its states. A value for the DEFAULT state must be provided. If the PENDING or CONFIRMED states are missing, they will not be shown.

Trait Implementations§

Source§

impl Clone for MenuItem

Source§

fn clone(&self) -> MenuItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MenuItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MenuItem

Source§

fn default() -> MenuItem

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MenuItem

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MenuItem

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Part for MenuItem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,