gestalt-sdk 0.0.1-alpha.26

Rust SDK scaffolding and generated protocol bindings for Gestalt executable providers
Documentation
// Code generated by sdkgen. DO NOT EDIT.

//! Generated wire conversions for remote.proto.

use crate::codec::support::{from_wire_duration, from_wire_timestamp, to_wire_struct};
use crate::generated::v1;
use crate::remote::{
    CreateRemoteRequest, DeleteRemoteRequest, ListRemotesRequest, ListRemotesResponse, ProviderRef,
    RegistrationCheckRequest, RegistrationCheckResponse, Remote, RemoteProviderDefinition,
    RemoteProviderSummary, RemoteReachability, ServerIdentity, TunnelBootstrap, TunnelEndpoint,
};

/// Converts a native `CreateRemoteRequest` to its wire message.
pub(crate) fn to_wire_create_remote_request(value: CreateRemoteRequest) -> v1::CreateRemoteRequest {
    v1::CreateRemoteRequest {
        tunnel: value.tunnel.map(to_wire_tunnel_endpoint),
        providers: value
            .providers
            .into_iter()
            .map(to_wire_remote_provider_definition)
            .collect(),
        expected_generation: value.expected_generation,
    }
}

/// Converts a native `DeleteRemoteRequest` to its wire message.
pub(crate) fn to_wire_delete_remote_request(value: DeleteRemoteRequest) -> v1::DeleteRemoteRequest {
    v1::DeleteRemoteRequest {
        id: value.id,
        expected_generation: value.expected_generation,
    }
}

/// Converts a native `ListRemotesRequest` to its wire message.
pub(crate) fn to_wire_list_remotes_request(_value: ListRemotesRequest) -> v1::ListRemotesRequest {
    v1::ListRemotesRequest {}
}

/// Converts a wire `ListRemotesResponse` to its native message.
pub(crate) fn from_wire_list_remotes_response(
    value: v1::ListRemotesResponse,
) -> ListRemotesResponse {
    ListRemotesResponse {
        remotes: value.remotes.into_iter().map(from_wire_remote).collect(),
        server_identity: value.server_identity.map(from_wire_server_identity),
        tunnel: value.tunnel.map(from_wire_tunnel_bootstrap),
        lease_duration: value.lease_duration.map(from_wire_duration),
    }
}

/// Converts a native `ProviderRef` to its wire message.
pub(crate) fn to_wire_provider_ref(value: ProviderRef) -> v1::ProviderRef {
    v1::ProviderRef {
        kind: value.kind,
        name: value.name,
    }
}

/// Converts a native `RegistrationCheckRequest` to its wire message.
pub(crate) fn to_wire_registration_check_request(
    value: RegistrationCheckRequest,
) -> v1::RegistrationCheckRequest {
    v1::RegistrationCheckRequest {
        registration_id: value.registration_id,
        generation: value.generation,
        providers: value
            .providers
            .into_iter()
            .map(to_wire_provider_ref)
            .collect(),
    }
}

/// Converts a wire `RegistrationCheckResponse` to its native message.
pub(crate) fn from_wire_registration_check_response(
    value: v1::RegistrationCheckResponse,
) -> RegistrationCheckResponse {
    RegistrationCheckResponse {
        ready: value.ready,
        message: value.message,
    }
}

/// Converts a wire `Remote` to its native message.
pub(crate) fn from_wire_remote(value: v1::Remote) -> Remote {
    Remote {
        id: value.id,
        owner_subject_id: value.owner_subject_id,
        generation: value.generation,
        providers: value
            .providers
            .into_iter()
            .map(from_wire_remote_provider_summary)
            .collect(),
        reachability: value.reachability.map(from_wire_remote_reachability),
        server_spki_sha256: value.server_spki_sha256,
        created_at: value.created_at.map(from_wire_timestamp),
        updated_at: value.updated_at.map(from_wire_timestamp),
        last_checked_at: value.last_checked_at.map(from_wire_timestamp),
        last_successful_heartbeat_at: value.last_successful_heartbeat_at.map(from_wire_timestamp),
        last_error: value.last_error,
        lease_expires_at: value.lease_expires_at.map(from_wire_timestamp),
    }
}

/// Converts a native `RemoteProviderDefinition` to its wire message.
pub(crate) fn to_wire_remote_provider_definition(
    value: RemoteProviderDefinition,
) -> v1::RemoteProviderDefinition {
    v1::RemoteProviderDefinition {
        kind: value.kind,
        name: value.name,
        definition: value.definition.map(to_wire_struct),
    }
}

/// Converts a wire `RemoteProviderSummary` to its native message.
pub(crate) fn from_wire_remote_provider_summary(
    value: v1::RemoteProviderSummary,
) -> RemoteProviderSummary {
    RemoteProviderSummary {
        kind: value.kind,
        name: value.name,
    }
}

/// Converts a wire `RemoteReachability` to its native message.
pub(crate) fn from_wire_remote_reachability(value: v1::RemoteReachability) -> RemoteReachability {
    RemoteReachability {
        reachable: value.reachable,
        message: value.message,
    }
}

/// Converts a wire `ServerIdentity` to its native message.
pub(crate) fn from_wire_server_identity(value: v1::ServerIdentity) -> ServerIdentity {
    ServerIdentity {
        client_spki_sha256: value.client_spki_sha256,
    }
}

/// Converts a wire `TunnelBootstrap` to its native message.
pub(crate) fn from_wire_tunnel_bootstrap(value: v1::TunnelBootstrap) -> TunnelBootstrap {
    TunnelBootstrap {
        frps_address: value.frps_address,
        lease_duration: value.lease_duration.map(from_wire_duration),
    }
}

/// Converts a native `TunnelEndpoint` to its wire message.
pub(crate) fn to_wire_tunnel_endpoint(value: TunnelEndpoint) -> v1::TunnelEndpoint {
    v1::TunnelEndpoint {
        host: value.host,
        certificate: value.certificate,
        server_spki_sha256: value.server_spki_sha256,
    }
}