Trait ToValue

Source
pub trait ToValue {
    // Required methods
    fn to_value(&self) -> Value;
    fn value_type(&self) -> Type;
}
Expand description

Trait to convert a value to a Value.

Similar to other common conversion traits, the following invariants are guaranteed:

  • Invertibility: x.to_value().get().unwrap() == x. In words, FromValue is the inverse of ToValue.
  • Idempotence: x.to_value() == x.to_value().to_value(). In words, applying ToValue multiple times yields the same result as applying it once. Idempotence also applies the other way around: value.get::<Value>() is a no-op.

There is also the possibility to wrap values within values, see BoxedValue. All (un-)boxing needs to be done manually, and will be preserved under the conversion methods.

The conversion methods may cause values to be cloned, which may result in reference counter changes or heap allocations depending on the source and target type.

Required Methods§

Source

fn to_value(&self) -> Value

Convert a value to a Value.

Source

fn value_type(&self) -> Type

Returns the type identifer of self.

This is the type of the value to be returned by to_value.

Implementations on Foreign Types§

Source§

impl ToValue for &str

Source§

impl ToValue for &Path

Source§

impl ToValue for CoordType

Source§

impl ToValue for Layer

Source§

impl ToValue for RelationType

Source§

impl ToValue for Role

Source§

impl ToValue for StateType

Source§

impl ToValue for TextAttribute

Source§

impl ToValue for TextBoundary

Source§

impl ToValue for TextClipType

Source§

impl ToValue for TextGranularity

Source§

impl ToValue for ValueType

Source§

impl ToValue for Antialias

Source§

impl ToValue for Content

Source§

impl ToValue for DeviceType

Source§

impl ToValue for Extend

Source§

impl ToValue for FillRule

Source§

impl ToValue for Filter

Source§

impl ToValue for FontSlant

Source§

impl ToValue for FontType

Source§

impl ToValue for FontWeight

Source§

impl ToValue for Format

Source§

impl ToValue for HintMetrics

Source§

impl ToValue for HintStyle

Source§

impl ToValue for LineCap

Source§

impl ToValue for LineJoin

Source§

impl ToValue for Operator

Source§

impl ToValue for PathDataType

Source§

impl ToValue for PatternType

Source§

impl ToValue for RegionOverlap

Source§

impl ToValue for SubpixelOrder

Source§

impl ToValue for SurfaceType

Source§

impl ToValue for TextClusterFlags

Source§

impl ToValue for Colorspace

Source§

impl ToValue for InterpType

Source§

impl ToValue for PixbufAlphaMode

Source§

impl ToValue for PixbufError

Source§

impl ToValue for PixbufRotation

Source§

impl ToValue for AxisUse

Source§

impl ToValue for ByteOrder

Source§

impl ToValue for CrossingMode

Source§

impl ToValue for CursorType

Source§

impl ToValue for DevicePadFeature

Source§

impl ToValue for DeviceToolType

Source§

impl ToValue for DeviceType

Source§

impl ToValue for DragCancelReason

Source§

impl ToValue for DragProtocol

Source§

impl ToValue for EventType

Source§

impl ToValue for FullscreenMode

Source§

impl ToValue for GLError

Source§

impl ToValue for GrabOwnership

Source§

impl ToValue for GrabStatus

Source§

impl ToValue for Gravity

Source§

impl ToValue for InputMode

Source§

impl ToValue for InputSource

Source§

impl ToValue for ModifierIntent

Source§

impl ToValue for NotifyType

Source§

impl ToValue for OwnerChange

Source§

impl ToValue for PropMode

Source§

impl ToValue for PropertyState

Source§

impl ToValue for ScrollDirection

Source§

impl ToValue for SettingAction

Source§

impl ToValue for SubpixelLayout

Source§

impl ToValue for VisibilityState

Source§

impl ToValue for VisualType

Source§

impl ToValue for WindowEdge

Source§

impl ToValue for WindowType

Source§

impl ToValue for WindowTypeHint

Source§

impl ToValue for WindowWindowClass

Source§

impl ToValue for BusType

Source§

impl ToValue for ConverterResult

Source§

impl ToValue for CredentialsType

Source§

impl ToValue for DBusMessageByteOrder

Source§

impl ToValue for DBusMessageHeaderField

Source§

impl ToValue for DBusMessageType

Source§

impl ToValue for DataStreamByteOrder

Source§

impl ToValue for DataStreamNewlineType

Source§

impl ToValue for DriveStartStopType

Source§

impl ToValue for EmblemOrigin

Source§

impl ToValue for FileAttributeStatus

Source§

impl ToValue for FileAttributeType

Source§

impl ToValue for FileMonitorEvent

Source§

impl ToValue for FileType

Source§

impl ToValue for IOErrorEnum

Source§

impl ToValue for MemoryMonitorWarningLevel

Available on crate feature v2_64 only.
Source§

impl ToValue for MountOperationResult

Source§

impl ToValue for NetworkConnectivity

Source§

impl ToValue for NotificationPriority

Source§

impl ToValue for PasswordSave

Source§

impl ToValue for PollableReturn

Available on crate feature v2_60 only.
Source§

impl ToValue for ResolverError

Source§

impl ToValue for ResolverRecordType

Source§

impl ToValue for ResourceError

Source§

impl ToValue for SocketClientEvent

Source§

impl ToValue for SocketFamily

Source§

impl ToValue for SocketListenerEvent

Source§

impl ToValue for SocketProtocol

Source§

impl ToValue for SocketType

Source§

impl ToValue for TlsAuthenticationMode

Source§

impl ToValue for TlsCertificateRequestFlags

Source§

impl ToValue for TlsChannelBindingType

Available on crate feature v2_66 only.
Source§

impl ToValue for TlsDatabaseLookupFlags

Source§

impl ToValue for TlsError

Source§

impl ToValue for TlsInteractionResult

Source§

impl ToValue for TlsProtocolVersion

Available on crate feature v2_70 only.
Source§

impl ToValue for TlsRehandshakeMode

Source§

impl ToValue for UnixSocketAddressType

Source§

impl ToValue for ZlibCompressorFormat

Source§

impl ToValue for Align

Source§

impl ToValue for ArrowType

Source§

impl ToValue for AssistantPageType

Source§

impl ToValue for BaselinePosition

Source§

impl ToValue for BorderStyle

Source§

impl ToValue for BuilderError

Source§

impl ToValue for ButtonBoxStyle

Source§

impl ToValue for ButtonRole

Source§

impl ToValue for ButtonsType

Source§

impl ToValue for CellRendererAccelMode

Source§

impl ToValue for CellRendererMode

Source§

impl ToValue for CornerType

Source§

impl ToValue for CssProviderError

Source§

impl ToValue for CssSectionType

Source§

impl ToValue for DeleteType

Source§

impl ToValue for DirectionType

Source§

impl ToValue for DragResult

Source§

impl ToValue for EntryIconPosition

Source§

impl ToValue for EventSequenceState

Source§

impl ToValue for FileChooserAction

Source§

impl ToValue for FileChooserConfirmation

Source§

impl ToValue for FileChooserError

Source§

impl ToValue for IconSize

Source§

impl ToValue for IconThemeError

Source§

impl ToValue for IconViewDropPosition

Source§

impl ToValue for ImageType

Source§

impl ToValue for InputPurpose

Source§

impl ToValue for Justification

Source§

impl ToValue for LevelBarMode

Source§

impl ToValue for License

Source§

impl ToValue for MenuDirectionType

Source§

impl ToValue for MessageType

Source§

impl ToValue for MovementStep

Source§

impl ToValue for NotebookTab

Source§

impl ToValue for NumberUpLayout

Source§

impl ToValue for Orientation

Source§

impl ToValue for PackDirection

Source§

impl ToValue for PackType

Source§

impl ToValue for PadActionType

Source§

impl ToValue for PageOrientation

Source§

impl ToValue for PageSet

Source§

impl ToValue for PanDirection

Source§

impl ToValue for PolicyType

Source§

impl ToValue for PopoverConstraint

Source§

impl ToValue for PositionType

Source§

impl ToValue for PrintDuplex

Source§

impl ToValue for PrintError

Source§

impl ToValue for PrintOperationAction

Source§

impl ToValue for PrintOperationResult

Source§

impl ToValue for PrintPages

Source§

impl ToValue for PrintQuality

Source§

impl ToValue for PrintStatus

Source§

impl ToValue for PropagationPhase

Source§

impl ToValue for RecentChooserError

Source§

impl ToValue for RecentManagerError

Source§

impl ToValue for RecentSortType

Source§

impl ToValue for ReliefStyle

Source§

impl ToValue for ResizeMode

Source§

impl ToValue for RevealerTransitionType

Source§

impl ToValue for ScrollStep

Source§

impl ToValue for ScrollType

Source§

impl ToValue for ScrollablePolicy

Source§

impl ToValue for SelectionMode

Source§

impl ToValue for SensitivityType

Source§

impl ToValue for ShadowType

Source§

impl ToValue for ShortcutType

Source§

impl ToValue for SizeGroupMode

Source§

impl ToValue for SizeRequestMode

Source§

impl ToValue for SortType

Source§

impl ToValue for SpinButtonUpdatePolicy

Source§

impl ToValue for SpinType

Source§

impl ToValue for StackTransitionType

Source§

impl ToValue for TextDirection

Source§

impl ToValue for TextExtendSelection

Source§

impl ToValue for TextViewLayer

Source§

impl ToValue for TextWindowType

Source§

impl ToValue for ToolbarStyle

Source§

impl ToValue for TreeViewColumnSizing

Source§

impl ToValue for TreeViewDropPosition

Source§

impl ToValue for TreeViewGridLines

Source§

impl ToValue for Unit

Source§

impl ToValue for WidgetHelpType

Source§

impl ToValue for WindowPosition

Source§

impl ToValue for WindowType

Source§

impl ToValue for WrapMode

Source§

impl ToValue for ResponseType

Source§

impl ToValue for Alignment

Source§

impl ToValue for AttrType

Source§

impl ToValue for BidiType

Source§

impl ToValue for CoverageLevel

Source§

impl ToValue for Direction

Source§

impl ToValue for EllipsizeMode

Source§

impl ToValue for Gravity

Source§

impl ToValue for GravityHint

Source§

impl ToValue for RenderPart

Source§

impl ToValue for Script

Source§

impl ToValue for Stretch

Source§

impl ToValue for Style

Source§

impl ToValue for TabAlign

Source§

impl ToValue for Underline

Source§

impl ToValue for Variant

Source§

impl ToValue for Weight

Source§

impl ToValue for WrapMode

Source§

impl ToValue for bool

Source§

impl ToValue for char

Source§

impl ToValue for f32

Source§

impl ToValue for f64

Source§

impl ToValue for i8

Source§

impl ToValue for i32

Source§

impl ToValue for i64

Source§

impl ToValue for *mut c_void

Source§

impl ToValue for str

Source§

impl ToValue for u8

Source§

impl ToValue for u32

Source§

impl ToValue for u64

Source§

impl ToValue for Box<str>

Source§

impl ToValue for String

Source§

impl ToValue for Vec<String>

Source§

impl ToValue for Vec<GString>

Source§

impl ToValue for NonZero<i8>

Source§

impl ToValue for NonZero<i32>

Source§

impl ToValue for NonZero<i64>

Source§

impl ToValue for NonZero<u8>

Source§

impl ToValue for NonZero<u32>

Source§

impl ToValue for NonZero<u64>

Source§

impl ToValue for NonNull<c_void>

Source§

impl ToValue for Path

Source§

impl ToValue for PathBuf

Source§

impl ToValue for HyperlinkStateFlags

Source§

impl ToValue for Context

Source§

impl ToValue for Device

Source§

impl ToValue for ImageSurface

Source§

impl ToValue for Matrix

Source§

impl ToValue for RecordingSurface

Source§

impl ToValue for Rectangle

Source§

impl ToValue for RectangleInt

Source§

impl ToValue for Region

Source§

impl ToValue for Surface

Source§

impl ToValue for AnchorHints

Source§

impl ToValue for AxisFlags

Source§

impl ToValue for DragAction

Source§

impl ToValue for EventMask

Source§

impl ToValue for FrameClockPhase

Source§

impl ToValue for ModifierType

Source§

impl ToValue for SeatCapabilities

Source§

impl ToValue for WMDecoration

Source§

impl ToValue for WMFunction

Source§

impl ToValue for WindowHints

Source§

impl ToValue for WindowState

Source§

impl ToValue for AppInfoCreateFlags

Source§

impl ToValue for ApplicationFlags

Source§

impl ToValue for AskPasswordFlags

Source§

impl ToValue for BusNameOwnerFlags

Source§

impl ToValue for BusNameWatcherFlags

Source§

impl ToValue for ConverterFlags

Source§

impl ToValue for DBusCallFlags

Source§

impl ToValue for DBusCapabilityFlags

Source§

impl ToValue for DBusConnectionFlags

Source§

impl ToValue for DBusInterfaceSkeletonFlags

Source§

impl ToValue for DBusMessageFlags

Source§

impl ToValue for DBusObjectManagerClientFlags

Source§

impl ToValue for DBusProxyFlags

Source§

impl ToValue for DBusSendMessageFlags

Source§

impl ToValue for DBusServerFlags

Source§

impl ToValue for DBusSignalFlags

Source§

impl ToValue for DriveStartFlags

Source§

impl ToValue for FileAttributeInfoFlags

Source§

impl ToValue for FileCopyFlags

Source§

impl ToValue for FileCreateFlags

Source§

impl ToValue for FileMeasureFlags

Source§

impl ToValue for FileMonitorFlags

Source§

impl ToValue for FileQueryInfoFlags

Source§

impl ToValue for IOStreamSpliceFlags

Source§

impl ToValue for MountMountFlags

Source§

impl ToValue for MountUnmountFlags

Source§

impl ToValue for OutputStreamSpliceFlags

Source§

impl ToValue for ResolverNameLookupFlags

Available on crate feature v2_60 only.
Source§

impl ToValue for ResourceLookupFlags

Source§

impl ToValue for SettingsBindFlags

Source§

impl ToValue for SubprocessFlags

Source§

impl ToValue for TlsCertificateFlags

Source§

impl ToValue for TlsDatabaseVerifyFlags

Source§

impl ToValue for TlsPasswordFlags

Source§

impl ToValue for SocketMsgFlags

Source§

impl ToValue for AccelFlags

Source§

impl ToValue for ApplicationInhibitFlags

Source§

impl ToValue for CalendarDisplayOptions

Source§

impl ToValue for CellRendererState

Source§

impl ToValue for DestDefaults

Source§

impl ToValue for DialogFlags

Source§

impl ToValue for EventControllerScrollFlags

Available on crate feature v3_24 only.
Source§

impl ToValue for FileFilterFlags

Source§

impl ToValue for FontChooserLevel

Available on crate feature v3_24 only.
Source§

impl ToValue for IconLookupFlags

Source§

impl ToValue for InputHints

Source§

impl ToValue for JunctionSides

Source§

impl ToValue for PlacesOpenFlags

Source§

impl ToValue for RecentFilterFlags

Source§

impl ToValue for RegionFlags

Source§

impl ToValue for StateFlags

Source§

impl ToValue for StyleContextPrintFlags

Source§

impl ToValue for TargetFlags

Source§

impl ToValue for TextSearchFlags

Source§

impl ToValue for ToolPaletteDragTargets

Source§

impl ToValue for TreeModelFlags

Source§

impl ToValue for FontMask

Source§

impl<'a> ToValue for &'a [&'a str]

Source§

impl<'a> ToValue for [&'a str]

Source§

impl<T> ToValue for Option<T>

Blanket implementation for all optional types.

Source§

impl<T> ToValue for &T
where T: ToValue + StaticType,

Blanket implementation for all references.

Implementors§