Defined the RecordingService and the TranscribingService protocols in the Recording package tracker.

This commit is contained in:
2026-07-03 21:33:07 +02:00
parent cc82e4fbf2
commit 31b778a36e
3 changed files with 126 additions and 0 deletions
@@ -0,0 +1,53 @@
import Foundation
/// A service that captures audio from a microphone for the Recording feature.
///
/// ``RecordingView`` attaches the service to its model at initialization, so the audio capture can be swapped without touching the feature's
/// state machine for example, with a real microphone backend in the app, or with a mock in unit tests.
public protocol RecordingService: Sendable {
/// Starts a new audio recording from the microphone.
func start() async throws
/// Pauses the ongoing recording.
func pause() async throws
/// Resumes a paused recording.
func resume() async throws
/// Stops the recording.
///
/// - Returns: The audio captured since the recording started.
func stop() async throws -> Data
}
// MARK: - Services
/// The recording service used by default, which simulates the audio capture without touching a microphone.
public struct SimulatedRecordingService: RecordingService {
// MARK: Initializers
/// Creates a simulated recording service.
public init() {}
// MARK: Methods
/// Simulates the start of an audio recording.
public func start() async throws {}
/// Simulates the pause of an ongoing recording.
public func pause() async throws {}
/// Simulates the resumption of a paused recording.
public func resume() async throws {}
/// Simulates the stop of a recording.
///
/// - Returns: An empty audio payload.
public func stop() async throws -> Data {
.init()
}
}