Tauri Core API - v2.6.0
    Preparing search index...

    Class Size

    A size represented either in physical or in logical pixels.

    This type is basically a union type of LogicalSize and PhysicalSize but comes in handy when using tauri::Size in Rust as an argument to a command, as this class automatically serializes into a valid format so it can be deserialized correctly into tauri::Size

    So instead of

    import { invoke } from '@tauri-apps/api/core';
    import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';

    const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
    const validSize = size instanceof LogicalSize
    ? { Logical: { width: size.width, height: size.height } }
    : { Physical: { width: size.width, height: size.height } }
    await invoke("do_something_with_size", { size: validSize });

    You can just use Size

    import { invoke } from '@tauri-apps/api/core';
    import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';

    const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSize
    const validSize = new Size(size);
    await invoke("do_something_with_size", { size: validSize });

    2.1.0

    Index

    Constructors

    Properties

    Methods

    • Returns { [key: string]: { width: number; height: number } }

    • Returns { [key: string]: { width: number; height: number } }