#get access to ~/Music directory

51 messages · Page 1 of 1 (latest)

muted jolt
#

hi i am trying to write a rust music app as a complete noob i try to read different docs online but i am at a stop on this code
the play audio path is not found as it is also in src the code in it looks like this (second image)
plz be gentle even if i think my code looks like garbage

#

the play_audio file i found online and i hope i can make it work with this code

#

thx for any help

violet silo
#

you aren't declaring any modules

muted jolt
#

the //mod play_audio i experimented with ?
i will do search about how to declare thks

violet silo
#

yes
mod is what allows you to use multiple code files in the same crate

muted jolt
#

then it tells me play_auido(&path) is not a fonction

violet silo
#

because you're trying to call a module
when you want the function inside that module

muted jolt
#

so i need to use pub ? if i get that right ?

violet silo
#

if you want an item to be visible in parent modules, it needs to be pub

muted jolt
#

like this ?

violet silo
#

maybe
is this a second mod play_audio inside of the other mod play_audio?

muted jolt
#

yeah xd i was going to say this feeled wrong xd

violet silo
#

-modules

polar nexusBOT
muted jolt
violet silo
#

modules aren't functions

muted jolt
#

if i am not mistaken this time the 2 directories are linked i just need to call the fonction now ?

violet silo
#

don't do that

#

just do mod play_audio;

muted jolt
#

thats how its doc told me to do?

i will do just mod play_audio; as suggested

violet silo
muted jolt
#

is my english making me idiot because i didn't understand it wasn't a way of accomplishing the same result ?

violet silo
#

it's a strictly worse way of accomplishing the same result

muted jolt
#

but the play audio is still inacessible

#

nah sorry it say not a fonction

violet silo
#

because modules still aren't functions
modules contain functions

muted jolt
#

yeah i need to call it

fluid fog
#

You do not put prints inside a module.
You put prints in functions, and put functions in modules.

muted jolt
muted jolt
violet silo
#

sure
having a function named the same as the module might not be a good idea though

muted jolt
#

yeah i was arriving at that because after the docs say

#

to call the fonction

#

but it said the fonction is private

#

looking it up rn

violet silo
#

then make that function not private

fluid fog
#

Change fn play_audio to pub fn play_audio

muted jolt
# muted jolt

@fluid fog thats what i tried but we went for another way

fluid fog
muted jolt
#

but i think i missed something in docs so i will continue reading before anything

muted jolt
violet silo
muted jolt
#

pub before a fonction make it public to the root

muted jolt