Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/uniffi_macros/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  remote.rs

  Sprache: Rust
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


use proc_macro2::TokenStream;
use quote::quote;
use syn::{
    parse::{Parse, ParseStream},
    Ident, Token, Type,
};

pub struct RemoteTypeArgs {
    pub implementing_crate: Ident,
    pub sep: Token![::],
    pub ty: Type,
}

impl Parse for RemoteTypeArgs {
    fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
        Ok(Self {
            implementing_crate: input.parse()?,
            sep: input.parse()?,
            ty: input.parse()?,
        })
    }
}

pub fn expand_remote_type(args: RemoteTypeArgs) -> TokenStream {
    let RemoteTypeArgs {
        implementing_crate,
        ty,
        ..
    } = args;
    let existing_tag = quote! { #implementing_crate::UniFfiTag };

    quote! {
        unsafe impl ::uniffi::FfiConverter<crate::UniFfiTag> for #ty {
            type FfiType = <#ty as ::uniffi::FfiConverter<#existing_tag>>::FfiType;

            fn lower(obj: #ty) -> Self::FfiType {
                <#ty as ::uniffi::FfiConverter<#existing_tag>>::lower(obj)
            }

            fn try_lift(v: Self::FfiType) -> ::uniffi::Result<#ty> {
                <#ty as ::uniffi::FfiConverter<#existing_tag>>::try_lift(v)
            }

            fn write(obj: #ty, buf: &mut Vec<u8>) {
                <#ty as ::uniffi::FfiConverter<#existing_tag>>::write(obj, buf)
            }

            fn try_read(buf: &mut &[u8]) -> ::uniffi::Result<#ty> {
                <#ty as ::uniffi::FfiConverter<#existing_tag>>::try_read(buf)
            }

            const TYPE_ID_META: ::uniffi::MetadataBuffer =
                <#ty as ::uniffi::FfiConverter<#existing_tag>>::TYPE_ID_META;
        }

        ::uniffi::derive_ffi_traits!(local #ty);
    }
}

Messung V0.5 in Prozent
C=96 H=99 G=97

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.