Coder Social home page Coder Social logo

oaidl-safe's Introduction

oaidl

![Crates.io]![docs.rs(https://docs.rs/oaidl/badge.svg)]

A crate to convert common Rust types to common COM/OLE types, primarily for use in FFI - BSTR, SAFEARRAY, and VARIANT are the three implemented here.

This crate provides traits and trait implementations to make it easy and safe to convert between Rust types and the FFI-compatible data types.

For reference, a SAFEARRAY of VARIANTs corresponds to a C# object[]. A VARIANT is considered an object by C# interop.

Documentation

License

This project is distributed under the terms of the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.

oaidl-safe's People

Contributors

zerothlaw avatar

Stargazers

Wei Long avatar  avatar Alex avatar Chris A. avatar Ihor Ranchynskyi avatar

Watchers

 avatar James Cloos avatar

oaidl-safe's Issues

Ergonomics papercuts with use of Variant APIs

Thank you for your hard work with developing this crate! Also, ignore the title, because I don't have a full grasp of what I'm doing with my project, or what you have planned with this crate. I've been busy for the past month or so, but returned to your crate to see how best I could use it in my little project. I'm currently using the develop branch in my project because I like the introduction of the VariantWrapper trait, which enables dynamic dispatch. I had to abandon this line of attack - possibly because I'm not using the APIs in the best way - because the only type that implements VariantWrapper is Variants, and I therefore cannot return Variants from functions or methods, which I think would be a good thing to be able to do. What are your thoughts on this?

My next thought process was to enable method calls like what is demonstrated here. I'm having trouble with that because I can't seem to find the way to make conversion from a raw Rust type to its equivalent VARIANT so that users don't have to make the conversion before they give the method its argument. Are there any insights you can give on this?

Unsound BStringExt APIs

These functions should be marked unsafe:

oaidl-safe/src/bstr.rs

Lines 35 to 40 in 97e9c15

/// Manually and correct free the memory allocated via Sys* methods
fn deallocate_bstr(bstr: Ptr<u16>);
/// Convenience method for conversion to a good intermediary type
fn from_bstr(bstr: *mut u16) -> U16String;
/// Convenience method for conversion to a good intermediary type
fn from_pbstr(bstr: Ptr<u16>) -> U16String;

They are public and can be passed invalid pointers without any unsafe in calling code:

use oaidl::BStringExt;

fn main() {
    let explode = widestring::U16String::from_bstr(42 as _);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.