How to import github project WebRTC.rs - github

I am very new to Rust and found this package on cargo.io that is a Rust implementation of the javascript API WebRTC. Here's the link https://crates.io/crates/webrtc#toolchain. That said, I am having a trouble using the package as there is no documentation anywhere and I can't find anyone else who has used this package. I am totally lost right now. How can I get started?

Follow the instructions on the page: https://crates.io/crates/webrtc
If your Cargo.toml and webrtc are on the same directory level you can just paste the following into your Cargo.toml:
webrtc = { path = "webrtc", version = "0.0.6" }

Related

VSCode says "Failed to run custom build command" on cbindgen, but it actually works

I have a Rust (2021) lib. It compiled fine.
I added a build.rs file with this in it:
extern crate cbindgen;
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::Builder::new()
.with_crate(crate_dir)
.generate()
.expect("Unable to generate bindings")
.write_to_file("rush_engine.h");
}
Next, I added this to the bottom of Cargo.toml:
[build-dependencies]
cbindgen = "0.20.0"
Finally, I added a cbindgen.toml file with the contents of this:
https://github.com/eqrion/cbindgen/blob/master/template.toml
If I run 'cargo build' the .h file appears as expected and there's no errors from cargo in the terminal window.
However, VS Code has the entire Cargo.toml underlined under every word with red squiggles and there's an error message at the bottom saying 'failed to run custom build command for lib_name'.
I cannot find a solution to this (have removed everything and re-added, cleaned out target folder, etc) and though it's not breaking anything, it's kinda off-putting that this glaring error keeps showing.
Any pointers on how to solve this would be grately appreciated.
Cheers
Jase
Additional requested info:
The Cargo.toml at issue looks like this:
[package]
name = "rush_engine"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "staticlib"]
[dependencies]
chrono = "0.4"
[build-dependencies]
cbindgen = "0.20.0"
The VSCode extensions I'm using are:
rust-lang.rust (version 0.7.8)
...that's literally it. I don't see anything else rust related in running extensions.
Something Francis Gagné (thanks!) said got me wondering and experimenting. That's how I found a solution.
The solution (for me) was uninstall the official Rust extension, then install the rust-analyzer extension. This seems to have the exact same functionality, and it's not red-squiggling my entire Cargo.toml file, too!

Source "#openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File import callback not supported

I've imported the Open Zeppelin ERC721 token standard into my VS Code with the Solidity extension, but see the following warnings on all my OZ import statements:
Screenshot of error
Why is this happening and what is the workaround for this warning?
What I've tried:
change default workspace compiler to localNodeModule (began to throw other warnings like on the pragma solidity line)
Example of solution I've tried
Just install the Solidity+Hardhat Extension ,this will take care of the errror.
run below command
npm install #openzeppelin/contracts
Change the import line like this
import "./node_modules/#openzeppelin/contracts/token/ERC721/ERC721.sol";
You could try this solution here, the only one that helped me.
https://stackoverflow.com/a/72241149/7537543
When you compile programmatically using solc, new syntax was introduced, which you have to include in compile.js.
// New syntax (supported from 0.5.12, mandatory from 0.6.0)
var output = JSON.parse(
solc.compile(JSON.stringify(input), { import: findImports })
);
You should have a helper function for finding imports
function findImports(relativePath) {
//my imported sources are stored under the node_modules folder!
const absolutePath = path.resolve(__dirname, 'node_modules', relativePath);
const source = fs.readFileSync(absolutePath, 'utf8');
return { contents: source };
}
Unfortunately I ran into this error too & just gave the path manually:
import "/home/ev1lclow3n/node_modules/#openzeppelin/contracts/token/ERC721/ERC721.sol";
This solved my error.
(I'm a linux user so path may differ for you)
Thanks ;-)
you have to manually guide the open zepplin import to its source file if you have it downloaded in your node modules then all you have to do is to change its path like this " ../node_modules/" and also make sure to use the latest extension of juan blanco's solidity extension and solidity and hardhat extension and if you are following a tutorial your first lines of codes would probably be import "hardhat/console.sol"; all you have to do here is to manually direct only this file to its designated place and the others would do it by themselves.
What you have to do is:
If you have "Solidity by Juan Blanco" for Truffle and "Solidity by Nomic Foundation" for Hardhdat, and if you are using Hardhat, disable the one by Juan Blanco and just use the one by Nomic Foundation, it just worked for me.
Screenshot
Make sure to create a Hardhat project (npx hardhat) and install:
npm install --save-dev "hardhat#^2.12.7" "#nomicfoundation/hardhat-toolbox#^2.0.0"
npm i #openzeppelin/contracts
Ok. That was a dumb question. Two things you have to do:
(1) Install the OZ library via
npm install #openzeppelin/contracts
(2) If you see Error HH606 (i.e. project can't compile), it's likely because The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config.. Ensure that your pragma version matches the version in your hardhat config.
Hope this helps.

how to bundle flutter ffi plugin

I am writing uber h3 plugin for flutter. I have working source code but I have problems with creating package more precisely I have problems to bundle libh3.so
Quick overview:
there is uber h3 c source code which is downloaded by. download_deps.sh
then android/build.gradle has build commands
externalNativeBuild {
cmake {
path "../ios/CMakeLists.txt"
}
}
then example/lib/main.dart has some initialization code.
initializeH3((String name) => Platform.isAndroid
? DynamicLibrary.open("lib${name}.so")
: DynamicLibrary.process());
but when I try to build it library file can not be found.
-I tried different locations.
It seems that library native .so is not bundled into application
But I don't konw why
According to tutorial https://flutter.dev/docs/development/platform-integration/c-interop
it should be bundled.
Here is the source code https://github.com/fmatuszewski/h3
I have managed to get this running, the pubspec.yaml was incorrectly formatted and required:
flutter:
plugin:
platforms:
android:
package: com.example.h3
pluginClass: H3Plugin
ios:
pluginClass: H3Plugin
Adding in at the end.
In doing this the package was properly attached.
libh3.so needs to be added into android/src/main/jniLibs to naturally be attached however I also moved the code:
final DynamicLibrary h3 = Platform.isAndroid
? DynamicLibrary.open("libh3.so")
: DynamicLibrary.process();
Back into h3.dart and removed main.dart to get this to run.
I think these were the main issues to get the code running. I had issues working out what was wrong as I am new to plugins - so it was a long process to sit and work out all the ins and outs. In doing this I ended up reworking all of the code to understand what was going on. If none of these points work or you wants eyes on the working code let me know and I can upload it to Github.

Unknown globals when installing ZXing Scanner

I have a Xamarin.Forms project which needs a QR code scanner. I found ZXing Scanner which seems to be a well established library for such purposes.
I installed it in the corresponding android project which worked without errors. When I wanted to build the app, Resource.Designer.cs was adjusted with the following lines:
global::ZXing.Mobile.Resource.Id.contentFrame = global::my.project.Droid.Resource.Id.contentFrame;
global::ZXing.Mobile.Resource.Layout.zxingscanneractivitylayout = global::my.project.Droid.Resource.Layout.zxingscanneractivitylayout;
global::ZXing.Mobile.Resource.Layout.zxingscannerfragmentlayout = global::my.project.Droid.Resource.Layout.zxingscannerfragmentlayout;
The problem is that I as well get the following errors:
'my.project.Droid.Resource.Id' does not contain a definition for 'contentFrame'
'my.project.Droid.Resource.Layout' does not contain a definition for 'zxingscanneractivitylayout'
'my.project.Droid.Resource.Layout' does not contain a definition for 'zxingscannerfragmentlayout'
I installed ZXing using NuGet but I as well tried to add the dlls manually. I get the same errors. Can anyone help me how to fix this?
Thank you in advance.
It's quite possible that your Resource.Designer.cs is not updating correctly:
Clean Project Build
Remove ZXing package.
Clean Project Build
Add ZXing package
Clean and Build Project once again
If it won't help:
https://kb.xamarin.com/customer/portal/articles/1638018-my-android-resource-designer-cs-file-will-not-update or https://forums.xamarin.com/discussion/13339/resource-designer-cs-not-regenerated/

Import Famo.us Ember-Cli project

I am trying to import famous into my application
When i create a breakpoint in the base index.html file in ember cli and look at what require seems to know about i see famo.us is there
in my brocfile i have tried the following
app.import('vendor/famous/famous.js', {
'famous/core/Context':''
});
app.import('vendor/famous/famous.js', {
'famous/core/Context':'default'
});
app.import('vendor/famous/famous.js');
this may be fixed by master of loader.js https://github.com/stefanpenner/loader.js/issues/25