| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| |
| // DO NOT EDIT IT MANUALLY. This file is generated by opendal/dev/src/generate/dotnet.rs. |
| |
| /// FFI-safe mirror of `opendal::Capability` used by the .NET binding. |
| /// |
| /// This struct intentionally mirrors fields from OpenDAL core capability, |
| /// but uses a stable C-compatible layout for cross-language interop. |
| /// |
| /// We keep this dedicated mirror because Rust internal type layout is not an |
| /// FFI contract and must not be marshaled directly across the ABI boundary. |
| /// |
| /// Absent `Option<usize>` limits are encoded as `usize::MAX`, which the C# |
| /// side maps back to `null`. |
| #[repr(C)] |
| #[derive(Default, Clone, Copy)] |
| pub struct Capability { |
| {%- for f in fields %} |
| /// {{ f.doc }} |
| pub {{ f.name }}: {% if f.is_bool %}bool{% else %}usize{% endif %}, |
| {%- endfor %} |
| } |
| |
| impl Capability { |
| /// Convert OpenDAL core capability into the FFI mirror payload. |
| pub fn new(cap: opendal::Capability) -> Self { |
| Self { |
| {%- for f in fields %} |
| {{ f.name }}: cap.{{ f.name }}{% if not f.is_bool %}.unwrap_or(usize::MAX){% endif %}, |
| {%- endfor %} |
| } |
| } |
| } |