Skip to main content

EditProject

Struct EditProject 

Source
pub struct EditProject {
    pub schema_version: u32,
    pub source: ClipRef,
    pub segments: Vec<TimelineSegment>,
    pub zooms: Vec<ZoomSegment>,
    pub background: BackgroundConfig,
    pub cursor: CursorConfig,
    pub crop: Option<CropRect>,
    pub aspect: AspectRatio,
    pub project_fps: u32,
    pub next_zoom_id: u32,
    pub cursor_track: Option<Vec<CursorSample>>,
    pub clicks: Option<Vec<ClickEvent>>,
}
Expand description

The serialized source of truth for one editing session.

The edited video is the ordered concatenation of segments; the cinematic framing comes from background / cursor / crop / aspect; cinematic punch-ins come from zooms. Nothing here is a GPU or media handle — the renderer and encoder re-derive every frame from this model at preview + export time.

Fields§

§schema_version: u32

On-disk schema version (see SCHEMA_VERSION).

§source: ClipRef

The source recording this project edits.

§segments: Vec<TimelineSegment>

Ordered timeline slices (trim / split / speed).

§zooms: Vec<ZoomSegment>

Cinematic zoom regions.

§background: BackgroundConfig

Background framing (wallpaper / padding / radius / shadow).

§cursor: CursorConfig

Cursor styling + auto-zoom detection settings.

§crop: Option<CropRect>

Optional crop / reframe of the source. None = full frame.

§aspect: AspectRatio

Output aspect ratio.

§project_fps: u32

Timeline frame rate (the editor’s time authority).

§next_zoom_id: u32

Monotonic counter for allocating fresh crate::ZoomIds (managed by edit operations in ED.2).

§cursor_track: Option<Vec<CursorSample>>

Per-frame cursor track captured at record time (ED.17). None for projects recorded before cursor capture, or when the macOS input-monitoring permission was denied. Drives the cursor overlay (ED.19).

§clicks: Option<Vec<ClickEvent>>

Click log captured at record time. Feeds auto-zoom detection (crate::telemetry::auto_zoom_segments) and the cursor click-ripple overlay (ED.19). None = no telemetry captured.

Implementations§

Source§

impl EditProject

Source

pub fn apply(&mut self, op: &EditOp) -> Result<(), EditError>

Apply an edit operation, mutating the project in place.

Prefer driving edits through crate::History, which makes them undoable; this is the underlying primitive.

§Errors

Returns EditError for an out-of-range segment index, an empty range, an unknown zoom id, or a split past the end of the timeline.

Source

fn apply_split(&mut self, at: Frame) -> Result<(), EditError>

Source

fn apply_trim( &mut self, index: usize, edge: TrimEdge, to: Frame, ) -> Result<(), EditError>

Source

fn apply_ripple_delete(&mut self, d0: Frame, d1: Frame) -> Result<(), EditError>

Source

fn apply_set_speed( &mut self, index: usize, timescale: f64, ) -> Result<(), EditError>

Source

fn apply_add_zoom(&mut self, zoom: ZoomSegment)

Source

fn apply_remove_zoom(&mut self, id: ZoomId) -> Result<(), EditError>

Source

fn apply_move_zoom( &mut self, id: ZoomId, start: Frame, end: Frame, ) -> Result<(), EditError>

Source

fn apply_set_zoom_ease( &mut self, id: ZoomId, ease: EditEase, ) -> Result<(), EditError>

Source

fn apply_set_crop(&mut self, rect: CropRect)

Source

pub fn check_invariants(&self) -> Result<(), String>

Check the project’s structural invariants. Used by tests (and a useful debugging aid): segments are non-empty and within the source; the zoom list is sorted, each zoom is non-empty, and every zoom id is below next_zoom_id.

§Errors

Returns a human-readable description of the first violated invariant.

Source§

impl EditProject

Source

pub fn from_recording(source: ClipRef) -> Self

Build a fresh project from a source recording: a single, full-length, real-time segment with default framing and no zooms — i.e. “the recording, untouched”, ready to edit.

Source

pub fn project_duration(&self) -> Frame

Total length of the edited timeline in project frames.

Source

pub fn segment_offsets( &self, ) -> impl Iterator<Item = (usize, Frame, &TimelineSegment)> + '_

Walk the segments with their cumulative project-frame start offset: yields (index, project_start, segment).

This is the single accumulation site for the segment→project-time walk — locate, segment_project_range, and the UI’s timeline lanes all derive from it instead of re-implementing the running sum.

Source

pub fn segment_project_range(&self, index: usize) -> Option<(Frame, Frame)>

The [start, end) project-frame range occupied by segment index, or None if the index is out of range.

Source

pub fn locate(&self, project_frame: Frame) -> Option<(usize, Frame)>

Locate a project frame: returns (segment index, source frame), or None if the frame is at/past the end of the timeline.

This is the core of the editor’s time model — it walks the segment list accumulating project-frame lengths until it finds the segment containing project_frame, then maps the within-segment offset to a source frame via that segment’s timescale.

Source

pub fn source_time(&self, project_frame: Frame) -> Option<Frame>

Map a project frame to the source frame the renderer should decode, or None past the end of the timeline.

Source

pub fn canvas_dims(&self) -> (u32, u32)

The composed-output canvas dimensions in pixels — the source’s longer edge reframed to the project’s aspect ratio (e.g. a 1920×1080 recording → 1080×1920 when aspect is Vertical). Both edges are even (H.264 chroma subsampling needs it). The source frame is letterboxed/pillarboxed into this canvas at render time, so changing the aspect reframes the export without distorting the content.

This is the unclamped canvas (the live preview composes at it directly); the export path additionally passes it through media::encode::fit_within_encoder_limits for the HW-encoder edge cap.

Source

pub fn zoom_cursor_target(&self, frame: Frame) -> (f32, f32)

The normalized (x, y) a cursor-targeted zoom should punch into at project frame — the cursor’s position there from cursor_track, or the frame centre (0.5, 0.5) when no track was captured. Pure; the basis for the editor’s “zoom to cursor” authoring action.

Source

pub fn generate_auto_zooms(&mut self) -> usize

Generate auto-zoom blocks from the captured click log (ED.17 — the “Auto-Zoom: detect from cursor” feature). Returns the number generated.

A no-op (returns 0) unless detection is enabled (CursorConfig::auto_zoom), a click log is present, and no zooms exist yet — so a freshly recorded clip arrives already punched-in on its click clusters, while a re-opened edit keeps the zooms the user already tuned (the generator never clobbers an existing list). The blocks are ordinary editable ZoomSegments (crate::telemetry::auto_zoom_segments) — the user nudges, deletes, or retunes them like any other zoom.

Trait Implementations§

Source§

impl Clone for EditProject

Source§

fn clone(&self) -> EditProject

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EditProject

Source§

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

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

impl<'de> Deserialize<'de> for EditProject

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 PartialEq for EditProject

Source§

fn eq(&self, other: &EditProject) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for EditProject

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 StructuralPartialEq for EditProject

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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,