►
Description
The talk will show and explain how pace and his collegues were able to create a library in Rust which had to be compiled to Android, iOS and WASM at the same time.
Follow us on Twitter: https://twitter.com/rustlatamconf
A
A
Yeah
so
interoperability.
When
people
talk
about
this,
usually
they're
talking
about
FFI.
So
does
anybody
know
what
FF
is
like
raise
your
hands?
That's
a
lot
of
people,
so
FFI
stands
for
foreign
function
interface.
So,
basically,
when,
like
a
probing
programming,
language
has
like
its
standard
library,
its
syntax,
a
lot
of
things
and
one
of
the
things
that
the
most
popular
one
ones
have
is
a
way
to
talk
to
the
external
world.
So
basically,
let's
say
you
have
created
those
awesome,
rust
functions,
I
think
actually
the
it's
not
very
easy
to
see.
A
So
let's
say
you
have
created
those
awesome,
rust
functions
and
you
want
to
use
them
and
you
need
to
create
I,
don't
know,
know
JSF
or
whatever,
and
you
want
to
use
them.
So
you
can
basically
go
to
use,
create
your
program
and
consume
them
using
the
FFI.
So
rust
has
a
way
to
externalize
externalize
things
and
also
consume
things
from
the
external,
also
other
languages.
Have
that
features.
A
A
They
use
some
Python
libraries
like
to
do
common
things
to
this
domain
and
some
of
the
what
those
libraries
are
actually
written
in
c
and
basically
they
do
wrappers
around
the
c
code
and
get
some
C
performance
out
of
that.
So
that's
pretty
cool.
You
can
also
use
existing
code
or
libraries.
So
let's
say
there's
this
new
language
and
you
can't
create
a
GUI
application
for
it.
So
there's
no
libraries
for
it,
so
you
can
basically
get
create
a
wrapper
around
I,
don't
know
some
ctk
library
using
FFI.
A
So
basically
you
talk
to
a
library
externally,
and
you
can
do
that
on
your
cool
new
language.
You
can
also
do
if
a
fight
to
actually
concentrate
common
logic
in
one
like
one
library.
So
basically
I'm
at
my
company
Pagar
me
it's
a
payments
company
in
brazil
we're
actually
we
have
an
Android
app
and
iOS
app
a
web
app
and
a
dotnet
app
that
all
of
them
need
to
talk
to
that
payment
terminal,
though
that
thing
you
put
your
credit
card
and
lose
money,
you
know.
A
So
basically
we
have
a
sea
library
that
actually
builds
the
commands
for
that
machine.
For
that
payment
terminal,
but
it's
actually
written
in
C,
we
are
rewriting
it
to
use
rust
for
various
reasons.
I
won't
get
into
that
here,
but
you
can
basically
concentrate
this
common
logic
in
one
library
and
consume
it
in
various
places.
A
But
how
to
do
this
in
rest,
so
Russ
has
various
features
to
do
this
or
tools
whatever
one
of
them
is
the
external
instant
declaration.
So
when
you
put
this
external
thing
before
the
function
declaration,
it
basically
means
you
want
to
do
two.
Is
it
externally,
so
this
C
string
basically
means
you
use
the
you
are
using
the
C
API.
You
can
use
other
API
it,
but
by
using
this
because
most
languages
have
a
way
to
talk
with
C
when
you
are
externalized
using
the
C
way,
they
can
read
your
rest
libraries.
A
A
There
are
a
lot
of
options
there
and
you
just
create
the
signature,
because
the
implementation
is
elsewhere
and
that's
the
idea
and
there's
the
know,
mango
and
attribute
that
basically
does
not
mango
the
function
name,
so
that
helps
other
compilers
that
are
not
rest,
compiler
to
actually
understand
the
function
name
and
that's
the
idea,
there's
also
wrapped
C,
which
basically
layouts
in
memory
your
structs
or
or
enums
in
a
c
way
that
helps
other
language
to
actually
understand
it.
But
this
is
not
necessary.
A
I
find
it
very
useful
for
enums,
but
you
can
use
Oh
pack.
Pointers
I
will
get
into
that
later,
but
if
this
is
actually
not
necessary
for
lot
of
cases,
so,
okay,
so
how
it's
the
workflow,
when
you're
building
a
library
for
an
extern
like
app
or
something
you
have
your
library
with
those
external
declarations.
So
we
have
a
lot
of
functions
there
that
you're
going
to
use
externally
you
build
them
to
the
target.
You
you
want.
So
when
you
do
only
cargo
build,
it
actually
uses
your
OS
and
architecture
and
everything
to
build
it.
A
A
But
this
j'ni
j'ni
is
basically
a
part
of
java,
like
in
simplified
terms,
a
part
of
Java
that
deals
with
the
external
road.
So
it's
Javas
FFI
and
you
can
maybe
create
a
job
or
cut
in
wrapper
around
it.
Those
functions,
those
external
functions.
For
so
let's
say
you
have
this
cool
struct
like
it
doesn't
actually
have
any
data
in
it,
but
it
could
have
doesn't
really
matter
for
the
example
but
and
then
you
need
to
prove
so
to
consume.
A
A
Basically
it
that's
the
way
the
Java
can
understand
your
function,
so
you
start
with
Java,
then
the
package
name
soku,
comm,
coo,
coo
android
project
and
then
it
and
then
your
class
and
then
a
method
so
that
basically
access
as
a
class
on
this
package,
and
then
this
function
receives
an
environment
and
this
and
the
environment.
Basically
it's
this
object
or
structure
or
whatever
that
you
can
do
things
on
the
on
java.
So
you
can
basically
create
object.
A
You
can
call
methods
on
classes,
you
can
do
all
kinds
of
stuff
there,
and
here
this
function
basically
instantiates
this
struct,
this
cool
struct
and
it
creates
a
disco.
Struct
allocates
it
in
the
heap
using
box
and
it
returns
a
pointer,
but
instead
of
weekend
retaining
a
simple
pointer,
I,
converted
it
to
a
long
type,
which
is
basically
just
an
integer,
a
bit
integer.
A
A
So
on
Java,
you
need
to
create
this
just
the
signature
of
that
external
method.
So
that's
the
cool
class.
That's
the
package
name,
the
method
return
type!
It's
all
like
that.
One
and
you
can
also
like
I,
don't
know,
create
a
private
value
that
contains
that
construct.
A
memory
address.
This
is
cotton.
By
the
way,
I
did
not
say
that,
but
yeah
for
iOS.
Basically,
it's
almost
the
same
thing,
but
you
get
dot
a
files
and
there's
a
tool
I
recommend
using
its
called
cargo
label.
A
You
can
do
the
cargo
build
target
for
everything
too,
but,
as
from
it's
pretty
complex,
to
actually
make
it
work
for
iOS,
so
just
use
Cargill,
it
would
work
perfectly,
but
instead
of
creating
a
like
a
class,
for
example,
here
we
created
this
class
to
actually
have
the
signature
on
Java
site
for
iOS.
You
need
to
create
a
C
bridging
header.
A
So
basically
it's
a
C
header
file
with
a
bunch
of
declarations
of
your
external
functions
of
your
wrist
functions,
report,
okay,
so
same
struct,
here
no
mango
and
extern
C,
C
syntax,
and
instead
of
returning
a
long
time
because
we
are
not
in
Java,
we
return
a
pointer
here
and
like
we
just
use
this
box
into
raw
which
just
get
gets
the
pointer
and
returns
to
to
the
other
side.
However,
like
this
works,
because
we
are
using
the
C
API
and
like
Swift
and
Objective,
C
interact
good
way
well
with
C.
A
So
that's
basically
just
like
a
normal,
regular,
C
pointer,
and
you
need
to
have
this-
this
bridging
header,
which
has
the
struct
and
the
method
that
returns.
That's
right,
so
this
struct
on
Russ.
It
actually
didn't
have
any
data,
but
here
I'm
doing
like
even
if
it
had,
you
can
just
create
an
opaque
pointer
definition.
Basically
in
a
pack
pointer
is
just
white
pointer,
I,
don't
know
if
you
have
programming
in
C,
but
basically
it's
a
pointer
that
can
point
to
anything
so
yeah
and
for
web
assembly.
A
It's
honestly
the
easiest
of
them
like
to
do
the
Interop.
There
are
two
libraries
that
help
a
lot
with
that
which
are
ways
my
engine
and
was
back.
Thank
you
Alex,
but
basically,
as
was
back
it's
more
like
a
command-line
tool
that
you
can
build
your
project
and
West
Byington
is
more
like
a
library.
It
actually
has
a
CLI,
but
I
honestly,
don't
use
it,
but
so
you
can
build
your
library
and
it
will
create.
A
Instead
of
the
regulars
target
folder,
you
get
a
pkg
folder
that
basically
will
contain
your
dot,
wasm
and
a
dot
J's
file.
So
it
actually
already
creates
a
wrapper
around
those
external
functions
on
JavaScript
and
the
cool
thing
about
this
pkg
folder
it.
Actually
you
can
create
a
web
app
that
actually
consumes
it
like
it
was
any
any
PM
package.
So
it's
very
good
for
using
like
it's
very
good,
okay,
so
the
same
thing
the
same
type
here,
but
here
you
can
see
that
we
can
just
return.
A
The
type
itself
like
we
can
just
call
my
stroke
nil,
just
by
putting
this
in
pouring
the
web
by
engine
attribute,
and
we
need
to
put
on
our
types
and
on
our
functions.
So
you
can
basically
write
regular
dress
code,
and
this
attribute
will
read
your
code
and
convert
to
that
dirty
box
thing.
So
it
will
deal
with
a
lot
of
stuff
for
you,
so
I
recommend
using
this
library
yeah,
so
okay,
but
I've
shown
all
of
these
and
but
how
to
do
all
of
those
three.
A
At
the
same
time,
on
a
rest
library,
there's
one
more
eirick,
it's
needed
to
do
this,
which
is
the
conditional
compilation
attribute.
So
there's
this
thing
in
Reverse
called
CFT.
It's
an
attribute
that
you
can
pass
a
basically
something
to
about
evaluate,
and
if
it's
true,
it
will
actually
compile
the
line
below
like
them.
For
example,
here
I
have
a
wise,
Mart
module
that
will
only
be
compiled
if
I'm,
actually
targeting
for
wasn't
32.
A
It's
the
same
thing,
but
you
use
it
for
your
dependencies
so
there
here
there
is
weather
engine
and
giasses
just
uses
a
library
inside
of
web
binding.
That
has
a
lot
of
JavaScript
types.
So
like
functions,
you
have
you
wait,
int,
you
int
eight
array.
You
have
a
lot
of
things
in
there,
okay,
so
how
to
structure
the
rest
library.
So
at
my
company
we
started
with
this
idea
and
that
actually
it's
almost
this
the
what
we
are
doing
we
on
the
labor
as
file.
A
We
put
our
common
modules
like,
of
course,
we
don't
have
a
common
module,
but
we
have
a
lot
of
modules
that
are
our
core
rest
library,
and
then
we
can
put
like
create
other
modules
that
use
that
camera
module
and
create
a
public
interface
for
a
specific
platform.
So
on
this
module,
if
we
basically
import
this
and
create
functions
that
webassembly
can
understand,
and
things
like
that,
just
the
same
for
iOS
and
Android.
A
So
that's
the
idea
we
had
but-
and
this
is
the
like
on
each
of
them,
you
create
a
public
interface
for
the
specific
platform
you
they
were
building
for
and
then
like
for
today,
I
didn't
like
our
projects
and
virtually
has
to
be
closed
at
source
because
of
recommendation
issues.
However,
I
did
a
project
for
just
for
today,
which
is
about
the
dome
fire
I.
Don't
know
if
you
have
played
doom,
it's
a
game
and
basically
there's
this
fire
on
the
menu
screen
that
you
can
like.
A
I,
basically
made
a
OS,
Android
and
web
app
that
rendered
in
sunscreen
and
the
logic
of
doing
this
is
on
rest.
So
the
render
part
is
on
the
the
platform
specific
app.
So
the
idea
is
that,
basically,
you
will
have
a
vector
of
pixels
of
bytes
or
numbers
whatever,
and
each
of
them
represents
a
number
from
0
to
36.
36
is
very
hot
0,
it's
not
a
hot
or
cold,
and
you
basically
a
vector
like
this.
Of
course
I.
A
Don't
I,
don't
export
it
as
just
a
pixels
variable
I
have
a
struct
that
has
that,
but
that's
the
idea.
So
basically
the
platform
only
reads
this
pixels
array
or
vector
whatever
and
resolve
all
of
those
numbers,
and
that's
dentist
intensity
of
the
fire
that
it
needs
to
render
on
screen.
That's
the
idea.
I
won't
get
into
many
details
of
how
it
works,
but
ok.
So
basically,
this
is
the
library
there.
Those
are
the
common
modules
and
here
are
the
three
specific
modules.
A
Here's
the
web
assembly,
one
like
I've
shown
and
the
Android
one,
but
here
you
can
see,
there's
no
iOS,
basically
for
like
we
discovered
when
we
were
working
on
our
project
at
Pagani
that
basically
exporting
functions
for
iOS
for.net
for
some
specific
platforms.
It's
very
similar.
It's
basically
the
same
thing,
so
we
really
created
justice
and
there
by
module
that
probably
can
be
consumed
by
other
platforms
that
are
not
iOS.
So
that's
the
idea.
This
is
the
iOS
one,
but
probably
works
for
other
platforms
too,
and
here
the
Android
one
actually
uses
the
standard.
A
The
file,
one
I,
don't
know
if
you
remember,
but
I've
shown
that
on
the
Android
one
you
basically
receive
long
types
and
convert
them
to
pointers
and
or
return
long
types
that
will
be
the
memory
address,
software
structs
so
that
you
can
call
methods
and
crate
structs
and
these
Android
module
just
converts
the
things
that
are
pointers
to
lungs,
or
vice
versa,
to
using
this
standard
for
fire
module.
So
here's
the
libraries
core
logic,
it's
basically
a
struct
with
a
lot
of
methods
and
that's
like
the
idea.
Here's
the
main
logic
and
here's
the
thing.
A
I've
shown
about
only
compile,
wasm
things
when
it's
needed:
okay
and
then
the
web
assembly
interface,
it's
very
simple
it
just
like,
creates
destruct
call
methods
on
it,
like
you
can
just
receive
mutable
references,
immutable
reference,
just
it
works
perfectly
I,
it's
very
good,
and
but
here
there's
one
interesting
thing:
basically,
we
needed,
like
I,
used
callbacks
in
this
project
and
there's
this
function
type,
which
is
from
JSC's.
Oh,
that
means
this
is
a
JavaScript
function
and
I
created
a
function
that
basically
converts
that
funk
that
extern
type
to
a
rus
type
like
something.
A
That's
not
platform-specific,
because
you
don't
want
to
keep
on
your
comma
modules
on
your
core
library,
things
that
are
platform
specific.
So
this
function.
Basically,
it's
something
like
this:
it
receives
the
JavaScript
function,
it
returns
the
box
with
anything
that
implements
the
function
trait
and
it
creates
this
box
and
puts
a
closure
in
it
that
calls
that
JavaScript
function.
So
that
way,
the
chorus
library
doesn't
know
what
is
a
JavaScript
function.
It
only
knows
things
that
are
rest
types
and
here's
basically
how
you
use
it.
Of
course,
we
don't
use
this
in
rest.
A
A
Okay,
so
for
iOS,
there's
the
stenographer
file
module,
which
creates
the
the
board
and
which
is
the
dead,
struct
I've
shown
returns.
The
pointer
and
the
functions
basically
receive
pointers
and
call
methods
on
them.
But
of
course,
do
no
checks
like
check
that
that
pointer
is
not
new,
then
you
can
maybe
convert
to
something
you
can
call
methods
and-
and
then
you
need
to
free
things.
So
basically
there's
this
box
into
Ralph
from
Ralph's
function
that
receives
a
pointer
and
then
converts
into
a
box
type.
A
So
a
box
type
when
it's
out
of
scope
it
will
free
that
memory.
So
that's
how
you
free
things
and
the
Android
interface
is
just
what
I've
shown
before,
but
it
receives
like.
For
example,
here
this
function
returns
a
J
long
and
basically
it
calls
this
tender
if
I'm
function,
that
creates
a
pointer
and
then
returns
it
as
a
long
time
and
then
the
functions
like
every
time.
You
want
to
call
a
method
on
it.
A
You
basically
receive
the
integer,
which
represents
the
memory
address
and
then
convert
it
as
a
pointer
so
that
this
tender
of
a
file
module
will
do
the
new
tracks
and
call
methods
in
it.
Okay,
this
is
the
project
like
you
can
check
it
later.
I
have
you
can
like
see?
Oh,
this
is
weird.
This
is
wrong.
A
This
is
good
and
yeah
that
that's
the
project
and
that's
basically
it
so
some
limitations
of
doing
Interop
like
with
rust
and
also
interrupts
in
general,
so,
for
example,
for
web
assembly,
at
least
using
the
web
engine
project,
which
is
very
big
and
most
users
project.
You
can
use
generics
or
typed
parlors
I'm.
Yet
so
you
can
use
them,
but
you
can't
export
any
type
that
uses
it.
Also,
there's
no
lifetime
parameters,
so
goodbye
references,
and
also
for
like
for
Android
one
thing
about
Java
that
at
least
like
there's
no
function,
pointers.
A
So
a
way
to
call
a
callback
is
basically
either
we
receive
an
object
and
call
a
specific
method
on
it
or
you
can
maybe
on
the
cotton
or
Java
interface,
receive
a
closure
store.
It
and
you
have
a
method
that
calls
it,
but
you
call
that
on
rest,
that's
kind
of
confusing
like
with,
but
yeah
there's
no
function
pointer.
So
you
have
to
do
some
things
to
actually
call
callbacks
on
iOS.
A
You
can
do
callbacks,
but
every
time
you
create
it,
you
pass
a
callback
to
to
see
because
on
iOS,
if
you
think
you're
just
doing
Interop
of
see,
you
basically
can't
use
data.
That's
on
an
object,
for
example,
you
can
use
if
you're
on
a
class.
You
can't
use
anything,
that's
related
to
cell.
For
this
you
need
to.
A
You
only
can
reference
things
that
are
either
received
on
the
closure
or
are
static
data,
so
that's
kind
of
annoying
too
and
for
all
of
them
at
least
not
much
for
web
assembly,
but
for
the
others,
one
other
ones.
There
are
very
few
examples
online,
like
they're.
Most
of
the
examples
are
either
you
pass
the
string
to
the
other
side
and
come
it
back
or
you
add,
in
the
two
numbers
or
you
print
something,
so
it's
very
annoying
to
find
something
useful
online.
A
There
are
some
references,
though
I
will
show
them
later,
but
it's
very
annoying
and
was
hard
to
do,
at
least
for
me
and
my
colleague,
the
biggest
challenge,
in
my
opinion,
was
to
actually
match
types
between
the
host
and
guest
language.
You
can
like
I,
really
literally
spend
hours
trying
to
like
okay
I
have
a
function
that
needs
to
receive
an
array
of
bytes
and
then
I.
Try
a
type
I
try
another
type,
I
tried
another
type
and
I.
A
Can
you
can
keep
hours
trying
to
actually
find
what
types
actually
match,
because
you
don't
have
examples
online,
so
at
least
I
had
this
problem.
It
was
very
annoying
and
some
references
that
helped
a
lot.
Please
help
me
for
well
assembly
there's
this
book
that
basically
creates
the
Conway's
Game
of
Life
I,
really
recommend
it.
It
actually
gets
kind
of
deep
on
webassembly
I
recommended
there's
one
Android
and
one
iOS
tutorial
by
Mozilla
that
actually
do
help
you
to
do
all
of
the
linking
process
and
how
to
build
your
library.
It
helped.
A
It
helped
me
a
lot,
but
it
is
a
hello
world,
but
it's
the
you
need
to
do
this.
Like
for
to
start
actually
doing,
FFI
with
android
iOS
and
for
4j
and
I
I
didn't
found
many
examples
using
rests
so
I
found
this
book.
That
was
very
helpful.
That
4c,
but
some
of
the
interfaces
that
Jay
and
I
the
J&I
has
on
see.
They
actually
are
similar
to
the
rest.
One
so
I
recommend
this
book
and
then
are
there.
There
are
two
talks
that
talk
about
FS
doing
ffiv.
First
I
recommend
them.
A
A
Take
care
because
you're
dealing
with
pointers
and
yeah
and
an
overview
of
rust,
rust
to
FF
I,
basically
shows
what
I've
shown
like
some
parts
and
I
recommend
watching
them,
and
I
would
like
to
thanks
to
some
people
most
of
them.
Actually
all
of
them
in
this
slide
are
from
my
company,
which
is
a
guy
I
mean
she
like
Marcela,
basically,
I
don't
have
a
Mac
so
to
compile
it
to
iOS
I,
basically
borrowed
a
Mac
from
her
2011
MacBook.
A
So,
thank
you
also
to
Phillippi,
basically
he's
the
guy
I'm
working
with
in
Pagar
me
at
this
project,
not
the
dome
fire
one
like
our
payment
terminal
project.
Those
people
are
actually
from
a
company
too.
They
I've
presented
to
them
a
lot
of
times
like
trying
to
like
practice
and
Alan.
Who
is
here
he
offered
to
actually
I
so
I
bet
I
could
use
his
computer,
but
I
did
ended
up
bringing
mine.
A
So
thanks
and
also
Pagani,
which
is
a
company
aware
for
a
lot
of
people,
helped
me
they're,
like
Camilla
Mars,
a
lot
of
people
there
Susanna
so,
and
also
thanks
to
those
three
people.
So
casiano
I
don't
know
him,
but
he
actually
has
a
project
of
doom
fire
during
the
doom
fire
on
Android,
because
I
don't
know
Android
and
iOS
I,
don't
know
how
to
render
things
on
screen.
So
basically,
this
project
helped
me
doing
the
rendering
part
marie-loup
the
same
for
iOS
and
Philippe
Editions.