Migrating from 0.5 to 0.6

0.6 is a minor release of a pre-1.0 crate, so it carries breaking changes. This page gathers the ones that need a code change. Each crate's CHANGELOG.md lists everything, in more detail. The DSL crates are not part of 0.6 and stay at 0.5.1.

Toolchain

0.6 needs Rust 1.89 or newer. 0.5 declared 1.85, but its source already used let chains, which stabilised in 1.88, and the H.264 decoder's SIMD dependency needs 1.89.

Core

  • TextureData has no public rgba field and no struct literals. Build one with TextureData::new(bytes, width, height), and use with_bytes for optional retained CPU data.
  • MeshData vertices and indices are Arc<Vec<_>>, and it gains morph data. Material gains fields.
  • ClipShape::RoundedRect gains corner_shape.
  • use_signal requires Clone.
  • DrawContext gains hooks with default bodies, so existing implementations still compile. draw_shader is one of them.

GPU

  • LayerCommand has more variants, so exhaustive matches need new arms, and Sample gains paint. DynamicImage, PrimitiveBatch and command struct literals gain fields.
  • render_mesh_data takes a DirectionalLight slice in place of light_dir and light_intensity.
  • blit_tight_texture_to_target takes rotate_z_rad: pass 0.0 for no rotation.
  • RendererConfig gains pipeline_cache_path.
  • The repr(C) structs grew, so custom uploads and shaders must follow the new field offsets, not only the sizes: GpuPrimitive 368 to 544 bytes, GpuImageInstance 192 to 208, SdfVertexInstance 128 to 144, GlassUniforms and MaskImageUniforms 16 to 32. PathVertex and LayerCompositeUniforms keep their size but use former padding for new fields.
  • FlowPipelineCache::compile takes a FlowShader. See Flow shaders.

Layout and app

  • PendingSubtreeRebuild replaces needs_layout with RebuildKind and gains epoch and tree_scope.
  • Button::new and with_content have new signatures.
  • WindowedContext::use_scroll_ref takes no argument. An explicit key is use_scroll_ref_keyed.
  • WindowedContext::use_state returns a reactive State<T>. State machines use use_fsm and use_fsm_keyed, and use_state_for is deprecated. The inherent use_effect is gone.
  • Public event, render and config records gain fields, so struct literals need ..Default::default() or the new fields.

Signals

Widgets bind to signals instead of State.

  • widgets::checkbox, checkbox_labeled and toggle take a Signal<bool>. radio_group and input_otp take a Signal<String>, and number_input takes a Signal<f64>.
  • The same holds for the cn widgets: checkbox, switch and toggle take a Signal<bool>, and radio_group, toggle_group, select, combobox and input_otp take a Signal<String>. number_input takes a Signal<f64>, slider a Signal<f32> or Signal<f64>, and pagination a signal of an integer or float.
  • .disabled(..), .label(..) and the placeholder of the text fields take a value, a Signal or a Computed, and follow it in place.
  • widgets::rich_text_editor::selection_toolbar takes the editor's version as a &Signal<u32>.

Component derives

BlincComponent ordinary field hooks now return Signal<T>. Use get, set and update on the signal and pass it directly to property bindings.

Named structs also generate NameProps and Name::props(...). Their fields store Reactive<T>; the constructor and fluent field setters accept IntoReactive<T>, including values, Signal and Computed. The original struct keeps its declared types. Forward generated props to bindings so changes apply in place. Consumers with named props depend directly on blinc_layout.

Explicit instance keys still isolate list items. Concrete generic types now have separate hook identities. See the derive guide.

CSS

  • theme(token) is removed. A theme's tokens are :root variables: write var(--primary), var(--radius-lg) and var(--shadow-md). The --shadow-* variables are real box-shadow lists.
  • Colours follow CSS. rgb() and rgba() components are 0 to 255, so rgb(0.2, 0.4, 0.9) is nearly black where it was a fraction. Named colours take their CSS values (orange is #ffa500, purple #800080, gray #808080).
  • @flow, the flow: property and the flow entries of css_style! and style! are removed. See below.

Flow shaders

Flow shaders are not part of CSS. They are drawn by a canvas.

0.50.6
@flow name { .. } in a stylesheet, flow: name;flow!(name, fragment, { .. }) and canvas(..).flow(shader)
div().flow(graph), FlowRef, RenderProps::flowCanvas::flow(shader), with .rounded(r) for the corners
flow! returned a FlowGraph, parsed at run timeflow! is a procedural macro: WGSL at compile time, a FlowShader constant
FlowPipelineCache::compile(&FlowGraph)compile(&FlowShader)
blinc::gpu::flow_codegenblinc_flow, re-exported as blinc::gpu::flow_to_wgsl

In the macro body, step types take underscore names (pattern_noise) and colours are hex integers (0x1a3a5a). blinc::layout::flow_shader(source) compiles @flow source text at run time. A shader that reads time animates by default, and Canvas::flow_loop and FlowClock control it.

cn components

Most cn widgets now take their look and motion from CSS rules instead of Rust. Where you set a colour, size or animation through a builder method that is removed below, write a rule for the widget's class instead.

  • cn::progress, cn::slider, cn::tabs, cn::spinner, cn::skeleton, cn::toast, cn::avatar, cn::breadcrumb and cn::pagination take colours and weights from rules. progress_animated, AnimatedProgress, SpinnerBuilder::duration_ms, Skeleton::shimmer, AnimatedSkeleton, and the slider's track_color, fill_color and thumb_color are removed.
  • Dialogs, sheets, drawers, toasts and tab panels enter and leave by CSS @keyframes rules, keyed on data-motion. The enter_animation, exit_animation and animation_duration builder methods are removed: a different motion is a rule of your own.
  • cn::collapsible, accordion, tree_view and sidebar open and close by rule, keyed on data-state. CollapsibleBuilder::{scale_anim, opacity_anim}, CollapsibleWithContent and AccordionBuilder::spring are removed.
  • The error look of cn::input and cn::textarea is the data-invalid rule. The cn-input--error and cn-textarea--error classes are gone, and so are .cn-toast--{info,success,warning,error}, .cn-progress--{sm,md,lg} and the cn-*--disabled classes.
  • The charts moved onto one shared plot: line_chart, area_chart, bar_chart, spark_line, threshold_line_chart, histogram and comparison_bar_chart take .series(..) and .data(..) as described in the blinc_cn changelog.
  • CN_STYLES sets the document's text colour, and cn::icon without a colour takes the surrounding text colour, as currentColor does.
  • cn::tree_view is rebuilt, with new part classes. The blinc_cn changelog lists them.