Files
noteflow/.rag/11-rust-grpc-types.md

4.4 KiB

NoteFlow Rust gRPC Client & Types

Location

client/src-tauri/src/grpc/

Architecture

Modular client using trait extensions for composition.

pub struct GrpcClient {
    channel: Channel,
    identity: Arc<IdentityManager>,
    state: Arc<AppState>,
}

Type Definitions (grpc/types/)

Core Types (core.rs)

pub struct ServerInfo {
    pub version: String,
    pub asr_model: String,
    pub asr_ready: bool,
    pub supported_sample_rates: Vec<i32>,
    pub max_chunk_size: i32,
    pub uptime_seconds: f64,
    pub active_meetings: i32,
    pub diarization_enabled: bool,
    pub diarization_ready: bool,
    pub state_version: i64,
    pub system_ram_total_bytes: Option<i64>,
    pub gpu_vram_total_bytes: Option<i64>,
}

pub struct Meeting {
    pub id: String,
    pub project_id: Option<String>,
    pub title: String,
    pub state: MeetingState,
    pub created_at: f64,
    pub started_at: Option<f64>,
    pub ended_at: Option<f64>,
    pub duration_seconds: f64,
    pub segments: Vec<Segment>,
    pub summary: Option<Summary>,
    pub metadata: HashMap<String, String>,
}

pub struct Segment {
    pub id: String,
    pub speaker: String,
    pub text: String,
    pub start_time: f64,
    pub end_time: f64,
    pub confidence: f32,
    pub speaker_id: Option<String>,
}

pub struct Summary {
    pub id: String,
    pub content: String,
    pub template_id: Option<String>,
    pub generated_at: f64,
    pub created_by_ai: bool,
}

pub struct Annotation {
    pub id: String,
    pub segment_ids: Vec<String>,
    pub annotation_type: AnnotationType,
    pub content: String,
    pub created_at: f64,
}

Enums (enums.rs)

pub enum MeetingState {
    Unspecified = 0,
    Created = 1,
    Recording = 2,
    Stopped = 3,
    Completed = 4,
    Error = 5,
}

pub enum AnnotationType {
    Unspecified = 0,
    ActionItem = 1,
    Decision = 2,
    Note = 3,
    Risk = 4,
}

pub enum ExportFormat {
    Unspecified = 0,
    Markdown = 1,
    Html = 2,
    Pdf = 3,
}

pub enum UpdateType {
    Unspecified = 0,
    PartialTranscript = 1,
    FinalTranscript = 2,
    SpeakerDiarization = 3,
}

pub enum Priority {
    Unspecified = 0,
    Low = 1,
    Medium = 2,
    High = 3,
}

Other Type Modules

  • asr.rs — ASR config types
  • streaming.rs — Streaming types
  • projects.rs — Project types
  • calendar.rs — Calendar types
  • webhooks.rs — Webhook types
  • preferences.rs — Preference types
  • identity.rs — Identity types
  • oidc.rs — OIDC types
  • sync.rs — Sync types
  • observability.rs — Observability types
  • results.rs — Result wrappers
  • hf_token.rs — HuggingFace types

Strategy B Type Modules (New)

  • analytics.rs — Analytics overview, speaker stats, entity analytics
  • assistant.rs — AI assistant request/response types
  • tasks.rs — Task types with status enum

Client Modules (grpc/client/)

File Purpose
core.rs Connection, auth, identity interceptor
meetings.rs Meeting CRUD
annotations.rs Annotation ops
diarization.rs Diarization requests
identity.rs User/workspace ops
projects.rs Project ops
preferences.rs Preference ops
calendar.rs Calendar sync
webhooks.rs Webhook ops
oidc.rs OIDC providers
sync.rs Integration sync
observability.rs Logs/metrics
asr.rs ASR config
streaming.rs Streaming config
hf_token.rs HuggingFace tokens
converters.rs Proto ↔ domain converters

Streaming (grpc/streaming/)

pub struct StreamManager {
    state: Arc<AppState>,
    grpc_client: Arc<GrpcClient>,
}

pub struct AudioStreamChunk {
    pub segment_id: String,
    pub samples: Vec<f32>,
    pub timestamp: f64,
    pub speaker: Option<String>,
}

pub struct StreamStateInfo {
    pub is_streaming: bool,
    pub buffered_samples: usize,
    pub segments_completed: u32,
}

Identity Interceptor

impl Interceptor for IdentityInterceptor {
    fn call(&mut self, mut request: Request<()>) -> Result<Request<()>, Status> {
        let metadata = request.metadata_mut();
        metadata.insert("x-user-id", user_id.parse()?);
        metadata.insert("x-workspace-id", workspace_id.parse()?);
        if let Some(token) = self.identity.access_token() {
            metadata.insert("authorization", format!("Bearer {token}").parse()?);
        }
        Ok(request)
    }
}